QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#198816 | #7104. Halting Problem | ckiseki | AC ✓ | 27ms | 4452kb | C++20 | 2.1kb | 2023-10-03 17:27:36 | 2023-10-03 17:27:37 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define all(x) begin(x), end(x)
#ifdef CKISEKI
#define safe cerr << __PRETTY_FUNCTION__ << " line " << __LINE__ << " safe\n"
#define debug(a...) debug_(#a, a)
#define orange(a...) orange_(#a, a)
template <typename ...T>
void debug_(const char *s, T ...a) {
cerr << "\e[1;32m(" << s << ") = (";
int cnt = sizeof...(T);
(..., (cerr << a << (--cnt ? ", " : ")\e[0m\n")));
}
template <typename I>
void orange_(const char *s, I L, I R) {
cerr << "\e[1;32m[ " << s << " ] = [ ";
for (int f = 0; L != R; ++L)
cerr << (f++ ? ", " : "") << *L;
cerr << " ]\e[0m\n";
}
#else
#define safe ((void)0)
#define debug(...) safe
#define orange(...) safe
#endif
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<tuple<string, int, int>> ops(n);
for (auto &[inst, x, y] : ops) {
cin >> inst >> x;
if (inst[0] == 'b') {
cin >> y;
y -= 1;
}
}
vector<vector<bool>> vis(n, vector<bool>(256));
int pc = 0;
uint8_t r = 0;
while (pc != n) {
if (vis[pc][r])
break;
vis[pc][r] = 1;
if (get<0>(ops[pc])[0] == 'a') {
r += get<1>(ops[pc]);
pc += 1;
} else if (get<0>(ops[pc])[1] == 'e') {
if (r == get<1>(ops[pc])) {
pc = get<2>(ops[pc]);
} else {
pc += 1;
}
} else if (get<0>(ops[pc])[1] == 'n') {
if (r != get<1>(ops[pc])) {
pc = get<2>(ops[pc]);
} else {
pc += 1;
}
} else if (get<0>(ops[pc])[1] == 'l') {
if (r < get<1>(ops[pc])) {
pc = get<2>(ops[pc]);
} else {
pc += 1;
}
} else if (get<0>(ops[pc])[1] == 'g') {
if (r > get<1>(ops[pc])) {
pc = get<2>(ops[pc]);
} else {
pc += 1;
}
} else {
__builtin_unreachable();
}
}
if (pc == n)
cout << "Yes\n";
else
cout << "No\n";
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3528kb
input:
4 2 add 1 blt 5 1 3 add 252 add 1 bgt 252 2 2 add 2 bne 7 1 3 add 1 bne 252 1 beq 252 1
output:
Yes Yes No No
result:
ok 4 lines
Test #2:
score: 0
Accepted
time: 27ms
memory: 4452kb
input:
1117 8 bgt 51 8 add 75 add 115 bne 40 3 beq 213 6 bgt 210 4 blt 228 7 bgt 60 2 6 bne 130 3 add 33 bne 74 4 blt 73 6 blt 63 5 bne 138 2 6 beq 131 2 bgt 90 3 add 127 bgt 195 1 blt 244 6 bne 20 3 3 add 53 bne 122 1 blt 251 2 9 add 102 add 161 bne 26 2 blt 5 8 beq 76 3 add 119 bgt 196 3 bne 239 8 blt 15...
output:
No Yes Yes No No Yes Yes No Yes No No No No Yes No No Yes No Yes No No Yes No No No Yes Yes Yes Yes Yes Yes No No No Yes Yes Yes Yes Yes Yes No No No No No Yes No Yes No No No Yes No No No No No Yes No Yes Yes Yes No Yes No Yes No Yes No No No No Yes No No Yes No No Yes No No No Yes Yes Yes Yes No Y...
result:
ok 1117 lines
Extra Test:
score: 0
Extra Test Passed