1 solutions
-
2
好水啊
STL的板子题,大家大概知道
queue
怎么用就行不懂
queue
的看过来:STL之queue容器详解_stl queue 最大长度-CSDN博客AC CODE
#include <iostream> #include <queue> using namespace std; queue <int> q; int n; int main () { cin >> n; for (int i = 1; i <= n; i++) { int op; cin >> op; if (op == 1) { int x; cin >> x; q.push(x); } if (op == 2) { if (q.size() == 0) { cout << "ERR_CANNOT_POP\n"; } else { q.pop(); } } if (op == 3) { if (q.size() == 0) { cout << "ERR_CANNOT_QUERY\n"; } else { cout << q.front() << "\n"; } } if (op == 4) { cout << q.size() << "\n"; } } return 0; }
- 1
Information
- ID
- 7510
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- 2
- Tags
- # Submissions
- 3
- Accepted
- 3
- Uploaded By