'commit'
This commit is contained in:
25
TangDou/AcWing/Queue/829_2.cpp
Normal file
25
TangDou/AcWing/Queue/829_2.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
const int N = 1e5 + 10;
|
||||
int q[N], hh, tt;
|
||||
int main() {
|
||||
int n;
|
||||
cin >> n;
|
||||
while (n--) {
|
||||
string op;
|
||||
cin >> op;
|
||||
if (op == "push") {
|
||||
cin >> q[++tt];
|
||||
if (tt == N) tt = 0; // 加冒了,就回到0
|
||||
} else if (op == "empty")
|
||||
hh == tt ? cout << "YES" << endl : cout << "NO" << endl;
|
||||
else if (op == "query")
|
||||
printf("%d\n", q[hh]);
|
||||
else {
|
||||
hh++;
|
||||
if (hh == N) hh = 0; // 加冒了,就回到0
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user