uva 11995 I Can Guess the Data Structure!
来源:互联网 发布:mysql osx 编辑:程序博客网 时间:2024/06/01 12:40
题目:I Can Guess the Data Structure!
思路:模拟。
代码:
#include<cstdio>#include<stack>#include<algorithm>#include<queue>#include<deque>using namespace std;int n;int main() {while(~scanf("%d",&n)) {bool fstack=1,fque=1,fpri=1;stack<int> a;queue<int> b;priority_queue<int> c;for(int i=1; i<=n; i++) {int x,y;scanf("%d%d",&x,&y);if(x==1) {a.push(y);b.push(y);c.push(y);}if(x==2) {if(fstack==0||a.empty()||a.top()!=y) fstack=0;else a.pop();if(fque==0||b.empty()||b.front()!=y) fque=0;else b.pop();if(fpri==0||c.empty()||c.top()!=y) fpri=0;else c.pop();}}if(fstack==0&&fque==0&&fpri==0) printf("impossible");else if(fstack==1&&fque==0&&fpri==0) printf("stack");else if(fstack==0&&fque==1&&fpri==0) printf("queue");else if(fstack==0&&fque==0&&fpri==1) printf("priority queue");else printf("not sure");printf("\n");}return 0;}
阅读全文
3 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
- 浅谈CSRF
- WebSocket实现Android客户端之间的简单通讯
- webstorm 2017 激活破解
- 【java学习准备2】servlet是线程安全的吗?
- MySQL 忘记密码怎么办
- uva 11995 I Can Guess the Data Structure!
- 物体空间姿态估计// Robust Planar Pose (RPP)algorithm
- CountDownLatch和CyclicBarrier的应用场景
- android利用WebSocket实现消息推送
- 致我的CSDN博
- 开发环境下未找到 BASE64Encoder及BASE64Decoder的解决办法
- Jupyter Notebook之web访问密码设定
- #和##
- IMP导数据文件,提示字符集与目标库不一致,后面导出的提示显示字段长度不够ORA-12899