hdu 1702 :ACboy needs your help again!(练习使用双端队列)
2013-04-05 21:31
369 查看
题目就是双端队列的基本操作
#include<iostream> #include<stdio.h> #include<deque>//双端队列头文件 #include<string.h> using namespace std; int main() { int n,m,x; char s[5],s1[4],s2[4]; while(scanf("%d",&n)!=EOF) { while(n--) { deque<int>q;//双端队列的定义(并清空) scanf("%d %s",&m,s); while(m--) { scanf("%s",s1); if(strcmp(s1,"IN")==0) { scanf("%d",&x); q.push_back(x); } else if(!q.empty()) { if(strcmp(s,"FIFO")==0) {printf("%d\n",q.front());q.pop_front();} else {printf("%d\n",q.back());q.pop_back();} } else printf("None\n"); } } } return 0; }
相关文章推荐
- HDU 1702 ACboy needs your help again! 栈和队列的使用
- HDU 1702 ACboy needs your help again!(栈+队列)
- HDU 1702 ACboy needs your help again!(附加优先队列)
- HDU 1702 ACboy needs your help again! (栈与队列)
- HDU:1702 ACboy needs your help again!(简单栈、队列)
- HDU 1702----ACboy needs your help again!(栈和队列)
- (hdu step 8.1.1)ACboy needs your help again!(STL中栈和队列的基本使用)
- HDU 1702 ACboy needs your help again! (栈和队列的模拟)
- hdu-1702 ACboy needs your help again!(栈和队列的结合)
- HDU 1702 ACboy needs your help again! (模拟栈和队列)
- hdu杭电1702 ACboy needs your help again!【栈和队列】
- HDU-1702 ACboy needs your help again!【栈与队列】
- hdu 1702 ACboy needs your help again!(模拟栈和队列)
- 【HDU】1702---ACboy needs your help again!(栈&&队列)
- HDU1702--ACboy needs your help again!(栈和队列)
- (hdu step 8.1.1)ACboy needs your help again!(STL中栈和队列的基本使用)
- HDU - 1702 - ACboy needs your help again!(栈&&队列)
- HDU 1702 ACboy needs your help again!(栈 队列 基础)
- HDU 1702 ACboy needs your help again!(栈和队列)
- HDU 1702 ACboy needs your help again!(模拟 队列 栈)