1 solutions
-
1
水题
这道题只是坑在数据范围,很多人因此第一遍没A。
没错,不开
long long
见祖宗,但开了long long
也见祖宗。。。得开
unsigned long long
哦吼。AC CODE
#include <iostream> #include <string> #include <stack> using namespace std; int t, n; int main () { cin >> t; while (t--) { stack <unsigned long long> s; cin >> n; for (int i = 1; i <= n; i++) { string op; cin >> op; if (op == "push") { unsigned long long x; cin >> x; s.push(x); } if (op == "pop") { if (s.size() == 0) { cout << "Empty\n"; } else { s.pop(); } } if (op == "query") { if (s.size() == 0) { cout << "Anguei!\n"; } else { cout << s.top() << "\n"; } } if (op == "size") { cout << s.size() << "\n"; } } } return 0; }
- 1
Information
- ID
- 5604
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- 2
- Tags
- # Submissions
- 5
- Accepted
- 2
- Uploaded By