UVa:11995 I Can Guess the Data Structure!
来源:互联网 发布:iapp源码手册2.0 编辑:程序博客网 时间:2024/05/23 12:49
水题,模拟即可。
注意无错的返回,需要判断是否为空。
#include <iostream>#include <cstdlib>#include <cstdio>#include <cstring>#include <cmath>#include <queue>#include <stack>#include <algorithm>#define MAXN 10000#define MOD 1000000007#define INF 2139062143#define ll long longusing namespace std;int main(){ int n; while(scanf("%d",&n)!=EOF) { bool pq=true,q=true,s=true; int p,t; stack<int> sk; priority_queue<int,vector<int>,less<int> > prique; queue<int> que; for(int i=0; i<n; ++i) { scanf("%d%d",&p,&t); if(p==1) { sk.push(t); prique.push(t); que.push(t); } else { if(sk.empty()||t!=sk.top()) s=false; if(prique.empty()||t!=prique.top()) pq=false; if(que.empty()||t!=que.front()) q=false; if(!sk.empty()) sk.pop(); if(!prique.empty()) prique.pop(); if(!que.empty()) que.pop(); } } if(!s&&!q&&!pq) puts("impossible"); else if((s&&q)||(q&&pq)||(pq&&s)) puts("not sure"); else if(s) puts("stack"); else if(pq) puts("priority queue"); else if(q) puts("queue"); } 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
- JDK6和JDK7中的substring()方法
- PHP_CURL1之模拟POST登陆
- 什么是内存泄漏
- 排序系列之快速排序
- 虚拟机下装oracle10G ASM
- UVa:11995 I Can Guess the Data Structure!
- 集合类接口和类层次关系图
- POJ 2240 Arbitrage
- Yii Framework 开发教程(34) Zii组件-AutoComplete示例
- 一个简单的EBNF范式的实现
- Yii Framework 开发教程(35) Zii组件-Button示例
- android 点击效果动画增强
- redhat 常用命令备忘
- 各类女性,各类人生