准备手写一个栈,结果。。。
#include <iostream>
#include <cstring>
typedef unsigned long long ULL;
using namespace std;
ULL T, n; // 懒得再写一个 int 快读了
ULL s[1000005], top = 0;
string readStr() {
string res;
char ch;
while (true) {
ch = getchar_unlocked();
if (ch == -1 || ch == ' ' || ch == '\n') break;
res.push_back(ch);
}
return res;
}
ULL readULL() {
ULL res = 0;
char ch;
while (true) {
ch = getchar_unlocked();
if (ch == -1 || ch == ' ' || ch == '\n') break;
if (ch >= '0' && ch <= '9') {
res *= 10;
res += ch-'0';
}
}
return res;
}
int main(int argc, const char * argv[]) {
// insert code here...
T = readULL();
while (T--) {
n = readULL();
while (n--) {
string op;
op = readStr();
if (op == string("push")) {
ULL x = readULL();
s[++top] = x;
}
if (op == string("pop")) {
if (top == 0)
printf("Empty\n");
else
top--;
}
if (op == string("query")) {
if (top == 0)
printf("Anguei!\n");
else {
printf("%llu\n", s[top]);
}
}
if (op == string("size")) {
printf("%llu\n", top);
}
}
top = 0;
}
return 0;
}