QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#156569 | #7104. Halting Problem | ucup-team206# | AC ✓ | 33ms | 13764kb | C++14 | 1.9kb | 2023-09-02 13:46:03 | 2023-09-02 14:34:14 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,t) for(int i=(s),_t=(t); i<=_t; ++i)
#define DOR(i,s,t) for(int i=(s),_t=(t); i>=_t; --i)
const int N=1e4+50;
char o[N];
int a[N],b[N];
int f[N][256];
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T,n;
cin >> T;
while(T--) {
cin >> n;
FOR(i,1,n) {
char s[5];
cin >> s;
o[i]=s[1];
if(o[i]=='d') cin >> a[i];
else cin >> a[i] >> b[i];
}
FOR(i,1,n) memset(f[i],0,sizeof(f[i]));
int v=0,k=1;
int r;
// cerr << a[1] << endl;
while(true) {
// cerr << k << ' ' << v << endl;
if(k==n+1) {
r=1;
break;
}
if(f[k][v]) {
r=0;
break;
}
f[k][v]=1;
if(o[k]=='d') {
// if(k==1) cerr << a[k] << endl;
// cerr << v << ' ' << a[k] << ' ' << v+a[k] << endl;
v=(v+a[k])%256;
// cerr << v << endl;
++k;
} else if(o[k]=='e') {
if(v==a[k]) {
k=b[k];
} else {
++k;
}
} else if(o[k]=='n') {
if(v!=a[k]) {
k=b[k];
} else {
++k;
}
} else if(o[k]=='l') {
if(v<a[k]) {
k=b[k];
} else {
++k;
}
} else {
if(v>a[k]) {
k=b[k];
} else {
++k;
}
}
}
cout << (r?"Yes":"No") << '\n';
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3704kb
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: 33ms
memory: 13764kb
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