#include <bits/stdc++.h>
using namespace std;
int q[10005], h = 0, t = -1;
int main() {
int n, m, x, cnt = 0;
cin >> n >> m;
n = min(n, m);
char c;
while(cin >> c && c != 'T') {
if(c == 'A') {
cin >> x;
// cout << h << " " << t << " " << n * 2 - h % n << endl;
if(t - h + 1 >= n * 2 - h % n) puts("ERROR:Full");
else q[++t] = x;
}
else if(c == 'D') {
if(h > t) puts("ERROR:Empty");
else cout << q[h++] << endl;
}
}
return 0;
}
PTA 堆栈模拟队列(最短代码)
最新推荐文章于 2023-10-24 21:44:49 发布