-
Notifications
You must be signed in to change notification settings - Fork 0
/
brandie_first_round.cpp
39 lines (37 loc) · 1.02 KB
/
brandie_first_round.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <iostream>
#include <cstdio>
#include <stack>
#include <queue>
using namespace std;
int main() {
int n;
while(cin>>n) {
stack<int> s;
queue<int> q;
priority_queue<int> pq;
bool cs=1, cq=1, cpq=1;
int cmd, value;
while(n--) {
cin>>cmd>>value;
if(cmd == 1) {
s.push(value);
q.push(value);
pq.push(value);
}
else {
if(s.empty() || s.top()!=value) cs=0;
else s.pop();
if(q.empty() || q.front()!=value) cq=0;
else q.pop();
if(pq.empty() || pq.top()!=value) cpq=0;
else pq.pop();
}
}
if(!cs && !cq && !cpq)cout<<"impossible"<<endl;
else if(cs && !cq && !cpq) cout<<"stack"<<endl;
else if(!cs && cq && !cpq) cout<<"queue"<<endl;
else if(!cs && !cq && cpq) cout<<"priority queue"<<endl;
else cout<<"not sure"<<endl;
}
return 0;
}