标签:blog http io ar os sp for on 2014
#include<iostream> #include<string> using namespace std; string a[20010],b[20010]; int main() { int n,m,i,flag; string x,y; while(cin>>n>>m) { flag=0; int top=0; int top1=0; int top2=0; for(i=0;i<m;i++) { cin>>x; if(x=="Add") { cin>>y; if(top<n) { a[++top]=y; } else { b[++top1]=y; } } if(x=="Del") { if(top<=0) { flag=1; } else if(top2<=top1) { a[top]=b[++top2]; } else if(top2>top1) { top--; } } if(x=="Out") { if(top2>top1) { flag=1; } else { top2++; } } } if(top>0 && flag==0) { while(top>0) { cout<<a[top--]<<endl; } } else cout<<"Error"<<endl; } return 0; }
标签:blog http io ar os sp for on 2014
原文地址:http://blog.csdn.net/r_misaya/article/details/41733549