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个. ...
随机推荐
- 黑马程序员 关于c# windows窗体关闭时线程未能完全退出问题(专题一)
<a href="http://edu.csdn.net"target="blank">ASP.Net+Android+IO开发S</a> ...
- JS高级——Object.prototype成员
基本概念 成员 描述 Object.prototype.__proto__ 指向当对象被实例化的时候,用作原型的对象. Object.prototype.hasOwnProperty() 返回一个布尔 ...
- JS——全选与全不选
1.每个子input标签都需要进行判断 2.使用开闭原则,一旦满足条件就改变默认值 3.在给主input标签注册事件时,要求主input标签的checked值赋值给子标签 <!DOCTYPE h ...
- (一)Python 学习第一天--基础知识,列表
1. .pyc文件 .pyc文件:在python3中,当模块运行时会自动生成在_pycache_文件夹中,其中c为compiled的缩写. Python是一门现编译后解释的语言,在运行时首先寻找.py ...
- JAVA趣味逻辑算法
/**已知4位同学中的一位数学考了100分,当小李询问这4位是谁考了100分时,4个人的回答如下: A说:不是我. B说:是C C说:是D. D说:他胡说. 已知三个人说的是真话,一个人说的是假话.现 ...
- 【LaTeX】对xelatex的中英文设置不同的字体
不建议用Ctex套装,不好用. 用MixTex+TexStudio! XeTeX处理中文非常方便,不需要任何设置,就能够使用系统中安装的TrueType和OpenType字体. MikTeX2.7中已 ...
- Centos安装smokeping教程
Centos安装smokeping教程 一 .安装基本依赖包 ntpdate time.windows.com #64bit rpm -Uhv http://apt.sw.be/redhat/el6/ ...
- Windows 8 常见教程
http://www.codeproject.com/Articles/439874/Web-service-on-Windows-Phone http://www.c-sharpcorner.com ...
- PHP 之转换excel表格中的经纬度
<?php set_time_limit(0); include './plugin/PHPExcel/PHPExcel.php'; include './plugin/PHPExcel/PHP ...
- Python 递归、匿名函数、map和filter day4
一.递归---函数自己调用自己 1.一个错误递归的例子: count=0 def hello(): global count count+=1 print("count %s"%c ...