QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#162294 | #7104. Halting Problem | ucup-team087 | AC ✓ | 103ms | 4228kb | C++14 | 2.5kb | 2023-09-03 08:15:04 | 2023-09-03 08:15:05 |
Judging History
answer
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using Int = long long;
template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
#define COLOR(s) ("\x1b[" s "m")
constexpr int MASK = 255;
char buf[110];
int N;
vector<string> S;
vector<int> V, K;
bitset<256> vis[10010];
int main() {
for (int numCases; ~scanf("%d", &numCases); ) { for (int caseId = 1; caseId <= numCases; ++caseId) {
scanf("%d", &N);
S.resize(N);
V.resize(N);
K.assign(N, -1);
for (int i = 0; i < N; ++i) {
scanf("%s%d", buf, &V[i]);
S[i] = buf;
if (S[i] != "add") {
scanf("%d", &K[i]);
--K[i];
}
}
for (int i = 0; i < N; ++i) {
vis[i].reset();
}
bool ans = false;
for (int i = 0, r = 0; ; ) {
if (i == N) {
ans = true;
break;
}
if (vis[i][r]) {
break;
}
vis[i].set(r);
if (false) {
} else if (S[i] == "add") {
(r += V[i]) &= MASK;
i = i + 1;
} else if (S[i] == "beq") {
i = (r == V[i]) ? K[i] : (i + 1);
} else if (S[i] == "bne") {
i = (r != V[i]) ? K[i] : (i + 1);
} else if (S[i] == "blt") {
i = (r < V[i]) ? K[i] : (i + 1);
} else if (S[i] == "bgt") {
i = (r > V[i]) ? K[i] : (i + 1);
} else {
assert(false);
}
}
puts(ans ? "Yes" : "No");
}
#ifndef LOCAL
break;
#endif
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3748kb
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: 103ms
memory: 4228kb
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