B3403 [Usaco2009 Open]Cow Line 直线上的牛 deque
deque真的秀,queue和stack。。。没啥用了啊。操作差不多,就是在前面加一个front||back_就行了。
题干:
题目描述
输入格式
输出格式
样例输入
- 10
- A L
- A L
- A R
- A L
- D R 2
- A R
- A R
- D L 1
- A L
- A R
样例输出
- 7
- 2
- 5
- 6
- 8
提示
题目来源
代码:
- #include<iostream>
- #include<cstdio>
- #include<cmath>
- #include<ctime>
- #include<queue>
- #include<algorithm>
- #include<deque>
- #include<cstring>
- using namespace std;
- #define duke(i,a,n) for(int i = a;i <= n;i++)
- #define lv(i,a,n) for(int i = a;i >= n;i--)
- #define clean(a) memset(a,0,sizeof(a))
- const int INF = 1e9 + ;
- typedef long long ll;
- typedef double db;
- template <class T>
- void read(T &x)
- {
- char c;
- bool op = ;
- while(c = getchar(), c < '' || c > '')
- if(c == '-') op = ;
- x = c - '';
- while(c = getchar(), c >= '' && c <= '')
- x = x * + c - '';
- if(op) x = -x;
- }
- template <class T>
- void write(T x)
- {
- if(x < ) putchar('-'), x = -x;
- if(x >= ) write(x / );
- putchar('' + x % );
- }
- deque <int> de;
- char s[];
- int num = ;
- int main()
- {
- int n;
- read(n);
- duke(i,,n)
- {
- scanf("%s",s);
- if(s[] == 'A')
- {
- scanf("%s",s);
- if(s[] == 'L')
- de.push_front(++num);
- else
- de.push_back(++num);
- }
- else
- {
- int x;
- scanf("%s",s);
- read(x);
- if(s[] == 'L')
- {
- while(x != )
- {
- // cout<<de.front()<<endl;
- de.pop_front();
- x--;
- }
- }
- else
- {
- while(x != )
- {
- // cout<<de.back()<<endl;
- de.pop_back();
- x--;
- }
- }
- }
- }
- while(!de.empty())
- {
- printf("%d\n",de.front());
- de.pop_front();
- }
- return ;
- }
B3403 [Usaco2009 Open]Cow Line 直线上的牛 deque的更多相关文章
- BZOJ 3403: [Usaco2009 Open]Cow Line 直线上的牛( deque )
直接用STL的的deque就好了... ---------------------------------------------------------------------- #include& ...
- BZOJ3403: [Usaco2009 Open]Cow Line 直线上的牛
3403: [Usaco2009 Open]Cow Line 直线上的牛 Time Limit: 3 Sec Memory Limit: 128 MBSubmit: 48 Solved: 41[S ...
- 3403: [Usaco2009 Open]Cow Line 直线上的牛
3403: [Usaco2009 Open]Cow Line 直线上的牛 Time Limit: 3 Sec Memory Limit: 128 MBSubmit: 71 Solved: 62[S ...
- 【BZOJ】3403: [Usaco2009 Open]Cow Line 直线上的牛(模拟)
http://www.lydsy.com/JudgeOnline/problem.php?id=3404 裸的双端队列.. #include <cstdio> #include <c ...
- BZOJ 3403: [Usaco2009 Open]Cow Line 直线上的牛(模拟)
直接双端队列模拟,完了= = CODE: #include<cstdio>#include<algorithm>#include<iostream>#include ...
- 149 Max Points on a Line 直线上最多的点数
给定二维平面上有 n 个点,求最多有多少点在同一条直线上. 详见:https://leetcode.com/problems/max-points-on-a-line/description/ Jav ...
- [Swift]LeetCode149. 直线上最多的点数 | Max Points on a Line
Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. ...
- LeetCode:149_Max Points on a line | 寻找一条直线上最多点的数量 | Hard
题目:Max Points on a line Given n points on a 2D plane, find the maximum number of points that lie on ...
- lintcode 中等题:Max Points on a Line 最多有多少个点在一条直线上
题目 最多有多少个点在一条直线上 给出二维平面上的n个点,求最多有多少点在同一条直线上. 样例 给出4个点:(1, 2), (3, 6), (0, 0), (1, 3). 一条直线上的点最多有3个. ...
随机推荐
- JS——思维拓展
1.阶乘求和:4的阶乘是1*2*3*4 <script> function jiechen(value) { var n = 1; for (var i = 1; i <= valu ...
- [Windows Server 2012] MySQL安全加固
★ 欢迎来到[护卫神·V课堂],网站地址:http://v.huweishen.com ★ 护卫神·V课堂 是护卫神旗下专业提供服务器教学视频的网站,每周更新视频. ★ 本节我们将带领大家:MySQL ...
- JAVA和JVM运行原理揭秘
这里和大家简单分享一下JAVA和JVM运行的原理,Java语言写的源程序通过Java编译器,编译成与平台无关的‘字节码程序’(.class文件,也就是0,1二进制程序),然后在OS之上的Java解释器 ...
- (转)分布式文件存储FastDFS(二)FastDFS安装
http://blog.csdn.net/xingjiarong/article/details/50559761 在前面的一篇中,我们分析了FastDFS的架构,知道了FastDFS是由客户端,跟踪 ...
- Django中图片的上传并显示
一.settings配置文件中配置 MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'medias').replace('\\', ...
- Vue动态创建组件方法
组件写好之后有的时候需要动态创建组件.例如: 编辑文章页面,正文是一个富文本编辑器,富文本编辑器是一个第三方的组件,点击添加章节的时候需要动态的创建一个富文本编辑器这个时候怎么处理呢. 富文本编辑器也 ...
- SpringBoot启动报jdbc连接池错误
如图,启动报连接池错误 项目中没有使用任何连接池,以为没用连接池的原因,所以配置了druid,一开始可以正常启动,但后来重启项目时仍旧报同样的错.网上找了资料,url中加useSSL=false,显式 ...
- wing ide破解
LicenseID='CN123-12345-12345-67891' # RequestCode='RL634-8363J-X7E8K-95XD3' RequestCode = 'RW61C-NN6 ...
- numpy.tile()
numpy.tile()是个什么函数呢,说白了,就是把数组沿各个方向复制 比如 a = np.array([0,1,2]), np.tile(a,(2,1))就是把a先沿x轴(就这样称呼吧)复制 ...
- perf-perf stat用户层代码分析
perf_event 源码分析 前言 简单来说,perf是一种性能监测工具,它首先对通用处理器提供的performance counter进行编程,设定计数器阈值和事件,然后性能计数器就会在设定事件发 ...