uva 11995 STL模拟
来源:互联网 发布:上淘宝开店要钱吗 编辑:程序博客网 时间:2024/05/05 02:40
记住 在pop之前 要先判断 是否 empty。runtime error 了 三次。
#include <iostream>#include <cstdio>#include <stack>#include <queue>using namespace std;stack<int> st;queue<int> qu;priority_queue<int> p_max;//priority_queue<int ,vector<int> , greater<int> > p_min;int flag_s,flag_q,flag_max;int flag_p,tmp,n;int opt,x,y;int main(){ freopen("1.in","r",stdin); while (scanf("%d",&n)!=EOF){ while (!st.empty()) st.pop(); while (!qu.empty()) qu.pop(); while (!p_max.empty()) p_max.pop(); flag_max =flag_q =flag_s =1; for (int i=0;i<n;i++) { scanf("%d%d",&opt,&x); if (opt==1) { if (flag_s) st.push(x); if (flag_q) qu.push(x); if (flag_max) p_max.push(x); } else if (st.empty() || qu.empty() || p_max.empty()) { flag_max =flag_q =flag_s =0; } else { if (flag_s) { if (st.empty()) {flag_s=0;} else{ y=st.top(); if (y!=x) flag_s=0; else st.pop(); } } if (flag_q) { y=qu.front(); if (y!=x) flag_q=0; else if (!qu.empty()) qu.pop(); } if (flag_max) { y=p_max.top(); if (y!=x) flag_max=0; else if (!p_max.empty()) p_max.pop(); } } } flag_p=flag_max; tmp=flag_q+flag_s+flag_p; if (tmp>1) printf("not sure\n"); else if (tmp==0) printf("impossible\n"); else { if (flag_s) printf("stack\n"); if (flag_q) printf("queue\n"); if (flag_p) printf("priority queue\n"); } } return 0;}
- uva 11995 STL模拟
- UVA 246 - 10-20-30 (模拟+STL)
- UVA-508 Morse Mismatches(STL模拟)
- UVA 10954 STL优先队列 模拟Huffmancode
- uva 11995(stl)
- UVA - 11995 I Can Guess the Data Structure! 猜猜数据结构(STL模拟)
- uva 11386 Triples (hash总是wa,于是模拟STL)
- UVa 540 Team Queue (STL list&queue模拟插队)
- UVA - 246 10-20-30 (模拟+STL)
- UVA - 101 The Blocks Problem(STL,模拟)
- UVa 101 The Blocks Problem 【STL】【vector】【模拟】
- UVA: I Can Guess the Data Structure!(stl模拟)
- uva 11995 猜测数据结构 入门与STL
- UVA 11995 (STL应用 13.08.07)
- uva 327 Evaluating Simple C Expressions 简易C表达式计算 stl模拟
- UVA 10815-Andy's First Dictionary(字符串模拟+排序+重复删除||STL-set)
- UVA 11988 STL deque (双端队列||链表模拟)
- uva 673( c++ STL)
- 小白学网络之五_TCPIP协议之RARP协议
- EclipseJEE安装SVN插件后提示Failed to load JavaHL Library的解决办法
- C#学习文章列表
- DropDownList 三级 联动 (转)
- Hibernate+spring整合相关
- uva 11995 STL模拟
- DevExpress 第三方控件汉化的全部代码和使用方法
- window.top.location.href不起作用
- C语言中不定参数个数的函数
- Cisco 命令:ipbroadcast-address
- iphone使用keychain来存取 uuid
- HTML和XHTML的不同
- 大致对Visual Studio 2008网站创建
- 你需要了解的未来:Andrew Ng,与他的Google Brain项目及人工智能实践