UVa 11991 I Can Guess The Data Structure(STL基础)
来源:互联网 发布:qq飞车高改天启数据 编辑:程序博客网 时间:2024/06/10 09:00
用stl中的3种数据结构依次去试,注意取之前要判断容器内是否是空的。
代码:
#include <cstdio>#include <cstring>#include <iostream>using namespace std;#include <queue>#include <stack>queue <int> Q;stack <int> S;priority_queue<int> P;void init(){while(!Q.empty()) Q.pop();while(!S.empty()) S.pop();while(!P.empty()) P.pop();}int main(){int N;while(~scanf("%d",&N)){init();int a=1,b=1,c=1;for(int i=1;i<=N;i++){int C,n;scanf("%d%d",&C,&n);if(C==1){Q.push(n);S.push(n);P.push(n);}else {if(!a||Q.empty()||Q.front()!=n) a=0;else Q.pop();if(!b||S.empty()||S.top()!=n) b=0;else S.pop();if(!c||P.empty()||P.top()!=n) c=0;else P.pop();}}int res=a+b+c;if(res==0) printf("impossible\n");else if(res>1) printf("not sure\n");else{if(a) printf("queue\n");else if(b) printf("stack\n");else printf("priority queue\n");}}return 0;}
0 0
- UVa 11991 I Can Guess The Data Structure(STL基础)
- uva 11995 I Can Guess the Data Structure!(STL)
- UVA: I Can Guess the Data Structure!(stl模拟)
- UVa 11995 I Can Guess the Data Structure! (STL)
- UVA 11995 I Can Guess the Data Structure!(STL应用)
- UVA - 11995 I Can Guess the Data Structure! STL模板
- 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! (STL的简单应用)
- uva 11995 - I Can Guess the Data Structure!(STL应用)
- UVA - 11995 I Can Guess the Data Structure! 猜猜数据结构(STL模拟)
- UVA 11995 I Can Guess the Data Structure! (STL的基本操作)
- 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! (基础数据结构练习!)
- UVA-11995 I Can Guess the Data Structure!(STL:各容器的简单运用)
- 纯js可定制的跨浏览器日期时间选择器插件
- 华为 Java 编程军规,每季度代码验收标准
- C语言函数指针基础
- ZOJ 3770 Ranking System
- 知乎API搜集
- UVa 11991 I Can Guess The Data Structure(STL基础)
- MyEclipse6.6 配置SVN的方法
- Win8下无法运行VC6.0解决方法
- jmeter内存溢出处理方式记录
- C/C++混合编程
- Debian配置JAVA环境报错之Could not find the main class: HelloWorld. Program will exit.
- POJ1088 滑雪 DP+记忆化搜索
- Codeforces Round #294 (Div. 2)——C.D
- 【精度问题】【HDU2899】Strange fuction