QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#166971 | #7104. Halting Problem | ucup-team1412 | AC ✓ | 63ms | 3724kb | C++11 | 1.3kb | 2023-09-06 21:59:44 | 2023-09-06 21:59:45 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int r;
int now;
struct step{
int type;
int v;
int k;
}s[100005];
int main()
{
int t;
cin>>t;
while(t--){
int n;
cin>>n;
now=0;
r=0;
for(int i=1;i<=n;i++){
string str;
cin>>str;
if(str=="add"){
int a;
cin>>a;
s[i].type=1;
s[i].v=a;
}
else if(str=="beq"){
int a,b;
cin>>a>>b;
s[i].type=2;
s[i].v=a;
s[i].k=b;
}
else if(str=="bne"){
int a,b;
cin>>a>>b;
s[i].type=3;
s[i].v=a;
s[i].k=b;
}
else if(str=="blt"){
int a,b;
cin>>a>>b;
s[i].type=4;
s[i].v=a;
s[i].k=b;
}
else if(str=="bgt"){
int a,b;
cin>>a>>b;
s[i].type=5;
s[i].v=a;
s[i].k=b;
}
}
for(int i=1;;){
if(s[i].type==1){
r+=s[i].v;
r%=256;
i++;
}
else if(s[i].type==2){
if(r==s[i].v){
i=s[i].k;
}
else i++;
}
else if(s[i].type==3){
if(r!=s[i].v){
i=s[i].k;
}
else i++;
}
else if(s[i].type==4){
if(r<s[i].v) i=s[i].k;
else i++;
}
else {
if(r>s[i].v) i=s[i].k;
else i++;
}
now++;
if(i==n+1){
cout<<"Yes"<<endl;
break;
}
if(now>256*n){
cout<<"No"<<endl;
break;
}
}
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3604kb
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: 63ms
memory: 3724kb
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