uva 11995 I Can Guess the Data Structure!
来源:互联网 发布:js 不等于空字符串 编辑:程序博客网 时间:2024/06/05 02:38
水题一道,做着玩
#include <stdio.h>#include <stack>#include <queue>using namespace std;int main(void){int n, i;int oper, data;queue<int> q;priority_queue<int> pq;stack<int> s;bool pq_possible, q_possible, s_possible;int count;//freopen("input.dat", "r", stdin);while(scanf("%d",&n) != EOF){while(!s.empty()) s.pop();while(!pq.empty()) pq.pop();while(!q.empty()) q.pop();pq_possible = q_possible = s_possible = true;for(i=1; i<=n; i++){scanf("%d %d", &oper, &data);if(1 == oper){if(s_possible)s.push(data);if(q_possible)q.push(data);if(pq_possible)pq.push(data);}else{if(s_possible){if(!s.empty()){if(s.top() == data){s.pop();}else{s_possible = false;}}else{s_possible = false;}}if(pq_possible){if(!pq.empty()){if(pq.top() == data){pq.pop();}else{pq_possible = false;}}else{pq_possible = false;}}if(q_possible){if(!q.empty()){if(q.front() == data){q.pop();}else{q_possible = false;}}else{q_possible = false;}}}}count = 0;if(s_possible)count ++;if(pq_possible)count ++;if(q_possible)count ++;if(count >= 2){printf("not sure\n");}else{if(count == 0){printf("impossible\n");}else{if(s_possible){printf("stack\n");}if(pq_possible){printf("priority queue\n");}if(q_possible){printf("queue\n");}}}}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
- Android ActionBar完全解析,使用官方推荐的最佳导航栏(上)
- linux环境使用Eclipse开发Android应用程序时使用真机调试方式
- 什么是REST风格
- 网页选项卡
- WPF学习笔记:获取ListBox的选中项
- uva 11995 I Can Guess the Data Structure!
- Android ActionBar完全解析,使用官方推荐的最佳导航栏(下)
- UVa 10719 - Quotient Polynomial
- 现在的我很幸福
- MySQL引擎
- SGU 102 prime水题
- Linux socket编程介绍
- Vim的使用
- Github的使用