HDU 1702 ACboy needs your help again!
2014-04-16 15:02
405 查看
题解:栈和队列的基本运用,熟练一下STL。
#include <iostream> #include <stack> #include <queue> using namespace std; int main(){ int t; scanf("%d",&t); while(t--){ int n,m; string str; cin>>n>>str; if(str=="FIFO"){ queue q; while(n--){ cin>>str; if(str=="IN")cin>>m,q.push(m); else{ if(q.empty())puts("None"); else printf("%d\n",q.front()),q.pop(); } } if(!q.empty())q.pop(); } else{ stack s; while(n--){ cin>>str; if(str=="IN")cin>>m,s.push(m); else{ if(s.empty())puts("None"); else printf("%d\n",s.top()),s.pop(); } } if(!s.empty())s.pop(); } } 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!(栈和队列)
- ACboy needs your help again! HDU - 1702
- 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!【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!
- ACboy needs your help again!-HDU - 1702
- hdu 1702 ACboy needs your help again!(模板)