?TLE
查看原帖
?TLE
1025329
_psycho楼主2024/10/3 22:05
#include <bits/stdc++.h>
#define int long long
#define il inline
using namespace std;

int stk[100005];
int Q[100005];

int top, head, tail;
priority_queue<int>PQ;
signed main() {
	int n;
	while (scanf("%lld", &n) != EOF) {
		top = 0;
		while (!PQ.empty())PQ.pop();
		head = 1, tail = 0;
		bool f1 = 1, f2 = 1, f3 = 1;
		int op, k;
		while (n --) {
			
//			cout << n << '\n';
			scanf("%lld %lld", &op, &k);
			if (op & 1) {
				if (f1)stk[++ top] = k;
				if (f2)Q[++ tail] = k;
				if (f3)PQ.push(k);
			} else {
				if (top){
					f1 = (f1 && stk[top --] == k);
					f2 = (f2 && Q[head ++] == k);
					f3 = (f3 && PQ.top() == k);
					PQ.pop();
				}
				
			}
		}
		int cnt = f1 + f2 + f3;
		if (!cnt)puts("impossible");
		else if (cnt >= 2)puts("not sure");
		else if (f1) puts("stack");
		else if (f2) puts("queue");
		else if (f3) puts("priority queue");
	}
	return 0;
}
2024/10/3 22:05
加载中...