水题(I Can Guess the Data Structure!,UVA 11995)
来源:互联网 发布:乡村旅游数据统计 编辑:程序博客网 时间:2024/06/04 23:34
#include<bits/stdc++.h>using namespace std;int n;stack<int>s;queue<int>q;priority_queue<int>p;bool a,b,c;int main(){ while(~scanf("%d",&n)) { while(!s.empty()) s.pop(); while(!q.empty()) q.pop(); while(!p.empty()) p.pop(); a=b=c=true; int op,x; while(n--) { scanf("%d %d",&op,&x); if(op==1) { s.push(x); q.push(x); p.push(x); } else { if(a) { if(s.empty()||s.top()!=x) a=false; else s.pop(); } if(b) { if(q.empty()||q.front()!=x) b=false; else q.pop(); } if(c) { if(p.empty()||p.top()!=x) c=false; else p.pop(); } } } if(!a&&!b&&!c) puts("impossible"); else if(a&&!b&&!c) puts("stack"); else if(!a&&b&&!c) puts("queue"); else if(!a&&!b&&c) puts("priority queue"); else puts("not sure"); } return 0;}
0 0
- UVA - 11995 I Can Guess the Data Structure!(水题)
- 水题(I Can Guess the Data Structure!,UVA 11995)
- 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!
- 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!
- Redis 4.0 新功能简介
- R语言-快速提取所有的组合
- Elasticsearch安装
- UIimage的缩放,马赛克处理,CVPixelBufferRef 转换为UIimage
- kafka集群部署以及java客户端测试
- 水题(I Can Guess the Data Structure!,UVA 11995)
- Nmon工具的使用以及通过nmon_analyse生成分析报表
- centos 安装 python3.4
- SSL P1615 Frogger
- Java四种线程池的使用
- SpringMvc常用依赖包
- AndroidStudio 内存泄露调试及MAT工具综合使用
- 开源工程学习笔记之Fastjson(Part 1)
- java实现冒泡法排序