2018_2_3_I Can Guess the Data Structure!_STL_模拟
2018-02-03 21:56
453 查看
https://vjudge.net/problem/UVA-11995
#include<iostream> 4000 ; #include<stack> #include<queue> #include<cstdio> using namespace std; const int N=1000+10; int n; int op ,x ; int main(){ while(scanf("%d",&n)!=EOF){ for(int i=0;i<n;i++) scanf("%d%d",op+i,x+i); stack<int> st; queue<int> q; priority_queue<int> heap; int flag1=true,flag2=true,flag3=true; for(int i=0;i<n;i++) if(op[i]==1)st.push(x[i]); else{ if(st.empty()){ flag1=false;break; }int u=st.top(); st.pop(); if(u!=x[i]){ flag1=false;break; } } for(int i=0;i<n;i++) if(op[i]==1)q.push(x[i]); else{ if(st.empty()){ flag2=false;break; }int u=q.front(); q.pop(); if(u!=x[i]){ flag2=false;break; } } for(int i=0;i<n;i++) if(op[i]==1)heap.push(x[i]); else{ if(heap.empty()){ flag3=false;break; }int u=heap.top(); heap.pop(); if(u!=x[i]){ flag3=false;break; } } if(!flag1&&!flag2&&!flag3){ puts("impossible");continue; } if(flag1&&!flag2&&!flag3){ puts("stack");continue; } if(!flag1&&flag2&&!flag3){ puts("queue");continue; } if(!flag1&&!flag2&&flag3){ puts("priority queue");continue; } puts("not sure"); } }
相关文章推荐
- UVA - 11995 - I Can Guess the Data Structure! STL 模拟
- UVA - 11995 - I Can Guess the Data Structure! STL 模拟
- 1/20集训一 STL E.(模拟stack queue priority_queue) I Can Guess the Data Structure!
- 判断STL的三种类型——UVA11995 - I Can Guess the Data Structure!
- UVA 11995 - I Can Guess the Data Structure!【stl】
- [UVA] 11995 - I Can Guess the Data Structure! [STL应用]
- UVA11995: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)
- 11995 - I Can Guess the Data Structure! uva
- I Can Guess the Data Structure!(水题,不过锻炼了stack,queue,priority的用法)
- 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:各容器的简单运用)
- STL UVA 11995 I Can Guess the Data Structure!