UVA - 11995 I Can Guess the Data Structure!
来源:互联网 发布:java下载64位 win7 编辑:程序博客网 时间:2024/06/05 10:47
题意:求满足操作的数据结构
思路:模拟
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <stack>#include <queue>using namespace std;int n,o,e,cs,s,q,pq;int main(){ while (scanf("%d",&n) != EOF){ stack<int > st; queue<int > qu; priority_queue<int > pqu; s = q = pq = 1; while (n--){ scanf("%d %d",&o,&e); if (o == 1){ st.push(e); qu.push(e); pqu.push(e); } else if (o == 2){ if (!st.empty()){ if (st.top() != e) s = 0; st.pop(); } else s = 0; if (!qu.empty()){ if (qu.front() != e) q = 0; qu.pop(); } else q = 0; if (!pqu.empty()){ if (pqu.top() != e) pq = 0; pqu.pop(); } else pq = 0; } } if (s && !q && !pq) printf("stack\n"); else if (!s && q && !pq) printf("queue\n"); else if (!s && !q && pq) printf("priority queue\n"); else if (!s && !q && !pq) printf("impossible\n"); else printf("not sure\n"); } return 0;}
0 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
- [iPhone高级] 基于XMPP的IOS聊天客户端程序(IOS端一)
- sax解析xml文件
- [iPhone高级] 基于XMPP的IOS聊天客户端程序(IOS端二)
- UML建模(1)——用例图的实现
- UML包图总结
- UVA - 11995 I Can Guess the Data Structure!
- [iPhone高级] 基于XMPP的IOS聊天客户端程序(IOS端三)
- SpringMVC+Json构建基于Restful风格的应用
- 第四章 微信飞机大战
- sd 卡写数据
- 设计模式之观察者模式与事件委托
- OpenMP的学习
- 从信息论到哈弗曼树
- 国内大学毕业论文LaTeX模板集合