Uva 11995 - I Can Guess the Data Structure!
来源:互联网 发布:太极拳实战 知乎 编辑:程序博客网 时间:2024/05/29 13:54
STL全部搞定
STL确实好,相似,不出错,好写
1Y
#include<stdio.h>#include<queue>#include<stack>std::queue<int>ty1;std::priority_queue<int>ty2;std::stack<int>ty3;int main(){int n;while(scanf("%d",&n)!=EOF){int i;int flag1=1,flag2=1,flag3=1;while(!ty1.empty())ty1.pop();while(!ty2.empty())ty2.pop();while(!ty3.empty())ty3.pop();int order,x;for(i=1;i<=n;i++){scanf("%d%d",&order,&x);if(order==1){ty3.push(x);ty2.push(x);ty1.push(x);}else {if(flag3&&!ty3.empty()){if(ty3.top()==x)ty3.pop();else flag3=0;}else flag3=0;if(flag2&&!ty2.empty()){if(ty2.top()==x)ty2.pop();else flag2=0;}else flag2=0;if(flag1&&!ty1.empty()){if(ty1.front()==x)ty1.pop();else flag1=0;}else flag1=0;}}int sum=flag1+flag2+flag3;if(sum>=2)printf("not sure\n");else if(sum==0)printf("impossible\n");else if(flag1)printf("queue\n");else if(flag2)printf("priority queue\n");else printf("stack\n"); }return 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
- 使用java程序生成excel文档程序
- RPM的使用
- makefile详解
- 还亲力亲为的蜡笔小新
- xml
- Uva 11995 - I Can Guess the Data Structure!
- 匪警请拨110,即使手机欠费也可拨通!为了保障社会秩序,保护人民群众生命财产安全,警察叔叔需要与罪犯斗智斗勇,
- DM3730 DSPLink在Linux下的环境搭建
- android中动态实现全屏和动态退出全屏方法
- WPF中窗体的层次问题
- 强制umount
- 安装vc6出现couldn't find acme setup的解决办法
- 指导教师的飞秋
- Android中获取SDCard的目录路径