QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#360872 | #7104. Halting Problem | YeongTree | AC ✓ | 25ms | 6972kb | C++17 | 1.6kb | 2024-03-22 13:11:26 | 2024-03-22 13:11:27 |
Judging History
answer
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <queue>
#include <numeric>
#include <set>
#include <map>
#include <random>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define piii pair<int, pii>
#define plll pair<long long, pll>
#define tiii array<int, 3>
#define tiiii array<int, 4>
#define ff first
#define ss second
#define ee ss.ff
#define rr ss.ss
typedef long long ll;
const int INF = (int)1e9 + 7;
using namespace std;
bool chc[101010][256];
map<string, int> M = {
{"add", 0},
{"beq", 1},
{"bne", 2},
{"blt", 3},
{"bgt", 4}
};
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int T; cin >> T;
while(T--)
{
int n; cin >> n;
for(int i = 0; i < n; ++i) for(int j = 0; j < 256; ++j) chc[i][j] = false;
int A[n][3];
for(int i = 0; i < n; ++i)
{
string s; int x; cin >> s >> x;
A[i][0] = M[s];
A[i][1] = x;
if(A[i][0])
{
int y; cin >> y; --y;
A[i][2] = y;
}
}
int i = 0; unsigned char x = 0;
bool ans = false;
while(1)
{
// cout << "!!" << i << ' ' << (int)x << '\n';
if(i == n) { ans = true; break; }
if(chc[i][x]) break;
chc[i][x] = true;
if(A[i][0] == 0) x += A[i][1], ++i;
else if(A[i][0] == 1) i = (x == A[i][1] ? A[i][2] : i + 1);
else if(A[i][0] == 2) i = (x != A[i][1] ? A[i][2] : i + 1);
else if(A[i][0] == 3) i = (x < A[i][1] ? A[i][2] : i + 1);
else if(A[i][0] == 4) i = (x > A[i][1] ? A[i][2] : i + 1);
}
cout << (ans ? "Yes" : "No") << '\n';
}
}
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3764kb
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: 25ms
memory: 6972kb
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