UVA 11995 I Can Guess the Data Structure!
来源:互联网 发布:99云呼软件 编辑:程序博客网 时间:2024/05/29 15:44
题意:根据所给的操作,猜测数据结构。
思路:直接模拟即可。
#include <iostream>#include<cstdio>#include<cstring>#include<string>#include<algorithm>#include<map>#include<queue>#include<stack>#include<cmath>#include<vector>#define inf 0x3f3f3f3f#define Inf 0x3FFFFFFFFFFFFFFFLL#define eps 1e-9#define pi acos(-1.0)using namespace std;int main(){ //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); int n; while(cin>>n) { queue<int>q; stack<int>s; priority_queue<int>p; int a,b,c; bool isqueue=true,isstack=true,isprior=true; for(int i=0;i<n;++i) { cin>>a>>b; if(a==1) { q.push(b); s.push(b); p.push(b); } else { if(q.empty()) isqueue=false; if(s.empty()) isstack=false; if(p.empty()) isprior=false; if(isqueue&&!q.empty()) { c=q.front(); q.pop(); if(b!=c) isqueue=false; } if(isstack&&!s.empty()) { c=s.top(); s.pop(); if(b!=c) isstack=false; } if(isprior&&!p.empty()) { c=p.top(); p.pop(); if(b!=c) isprior=false; } } } if(!isqueue&&!isstack&&!isprior) cout<<"impossible"<<endl; else if(isqueue&&!isstack&&!isprior) cout<<"queue"<<endl; else if(!isqueue&&isstack&&!isprior) cout<<"stack"<<endl; else if(!isqueue&&!isstack&&isprior) cout<<"priority queue"<<endl; else cout<<"not sure"<<endl; } return 0;}
- uva - 11995 - I Can Guess the Data Structure!
- Uva-11995-I Can Guess the Data Structure!
- Uva 11995 - I Can Guess the Data Structure!
- UVA 11995 I Can Guess the Data Structure!
- uva 11995 I Can Guess the Data Structure!
- uva 11995 I Can Guess the Data Structure!(STL)
- UVA 11995 I Can Guess the Data Structure!
- UVA 11995 I Can Guess the Data Structure!
- uva 11995 - I Can Guess the Data Structure!
- Uva 11995 - I Can Guess the Data Structure! (判断数据类型)
- UVa:11995 I Can Guess the Data Structure!
- UVA - 11995 I Can Guess the Data Structure!
- UVa 11995 I Can Guess the Data Structure! (STL)
- UVA 11995 I Can Guess the Data Structure!
- UVA 11995 I Can Guess the Data Structure!(STL应用)
- UVa 11995 I Can Guess the Data Structure!
- uva 11995 I Can Guess the Data Structure!
- 11995 - I Can Guess the Data Structure! uva
- DB2 ONLINE UTILITY 监控
- Ubuntu下source insight安装
- struts中过滤器与拦截器的区别
- maven的部署、遇到的问题和心得体会
- 甘特图
- UVA 11995 I Can Guess the Data Structure!
- C++模板中关键字typename与class的区别
- 不要小瞧v$mystat
- windows - create junction with mklink and remove junction with rmdir
- adb server is out of date. killing...
- 【java】BufferImage
- 向专业开发看齐
- malloc()之后,内核发生了什么?
- POJ 1166 高斯消元 疑惑的思考