0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-08 15:18:46 +00:00

B3614 【模板】栈

https://www.luogu.com.cn/record/130382070
This commit is contained in:
Baoshuo Ren 2023-10-19 18:47:54 +08:00
parent 6b0ec5b8c6
commit 13b4867010
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A

52
Luogu/B3614/B3614.cpp Normal file
View File

@ -0,0 +1,52 @@
#include <iostream>
#include <stack>
using std::cin;
using std::cout;
const char endl = '\n';
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while (t--) {
int n;
std::stack<unsigned long long> st;
cin >> n;
while (n--) {
std::string op;
cin >> op;
if (op == "push") {
unsigned long long x;
cin >> x;
st.emplace(x);
} else if (op == "pop") {
if (st.empty()) {
cout << "Empty" << endl;
} else {
st.pop();
}
} else if (op == "query") {
if (st.empty()) {
cout << "Anguei!" << endl;
} else {
cout << st.top() << endl;
}
} else if (op == "size") {
cout << st.size() << endl;
}
}
}
return 0;
}