UVA - 11995 I Can Guess the Data Structure!
2014-02-16 20:45
567 查看
题意:求满足操作的数据结构
思路:模拟
思路:模拟
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <stack> #include <queue> using namespace std; int n,o,e,cs,s,q,pq; int main(){ while (scanf("%d",&n) != EOF){ stack<int > st; queue<int > qu; priority_queue<int > pqu; s = q = pq = 1; while (n--){ scanf("%d %d",&o,&e); if (o == 1){ st.push(e); qu.push(e); pqu.push(e); } else if (o == 2){ if (!st.empty()){ if (st.top() != e) s = 0; st.pop(); } else s = 0; if (!qu.empty()){ if (qu.front() != e) q = 0; qu.pop(); } else q = 0; if (!pqu.empty()){ if (pqu.top() != e) pq = 0; pqu.pop(); } else pq = 0; } } if (s && !q && !pq) printf("stack\n"); else if (!s && q && !pq) printf("queue\n"); else if (!s && !q && pq) printf("priority queue\n"); else if (!s && !q && !pq) printf("impossible\n"); else printf("not sure\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! 猜猜数据结构(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! --抽象数据结构判断
- I Can Guess the Data Structure! uva11995
- I Can Guess the Data Structure! UVA11995
- uva 11995 I Can Guess the Data Structure!(STL)
- 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! (基本数据结构)
- UVA 11995 I Can Guess the Data Structure!
- uva 11995 I Can Guess the Data Structure! (STL的简单应用)
- (DS 《算法入门经典》)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!