QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#159766 | #7104. Halting Problem | ucup-team1412# | WA | 28ms | 6584kb | C++20 | 2.5kb | 2023-09-02 18:37:25 | 2023-09-02 18:37:27 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string s;
bool exist[10001][257];
ll r;
struct ide{
ll type;
ll v;
ll k;
}ii[10001];
/*int t;
int steps[100000+5];
ll houzhui[100000+5];
int ti,pos,len;*/
int main()
{
/*cin>>s;
len=s.length();
while(pos<=len-1)
{
steps[pos]=ti;
if()
}*/
ll t;
cin>>t;
while(t--){
ll n;
scanf("%lld",&n);
r=0;
for(ll i=1;i<=n;i++){
for(ll j=0;j<257;j++){
exist[i][j]=false;
}
}
for(ll i=1;i<=n;i++){
cin>>s;
if(s=="add"){
ii[i].type=1;
ll x;
scanf("%lld",&x);
ii[i].v=x;
}
else if(s=="beq"){
ii[i].type=2;
ll x,y;
scanf("%lld %lld",&x,&y);
ii[i].v=x,ii[i].k=y;
}
else if(s=="bne"){
ii[i].type=3;
ll x,y;
scanf("%lld %lld",&x,&y);
ii[i].v=x,ii[i].k=y;
}
else if(s=="blt"){
ii[i].type=4;
ii[i].type=2;
ll x,y;
scanf("%lld %lld",&x,&y);
ii[i].v=x,ii[i].k=y;
}
else{
ii[i].type=5;
ll x,y;
scanf("%lld %lld",&x,&y);
ii[i].v=x,ii[i].k=y;
}
}
for(ll i=1;;){
if(exist[i][r]==true){
printf("No\n");
break;
}
exist[i][r]=true;
switch(ii[i].type){
case 1:
r+=ii[i].v;
r%=256;
i++;
break;
case 2:
if(r==ii[i].v){
i=ii[i].k;
}
else i++;
break;
case 3:
if(r!=ii[i].v) i=ii[i].k;
else i++;
break;
case 4:
if(r<ii[i].v) i=ii[i].k;
else i++;
break;
case 5:
if(r>ii[i].v) i=ii[i].k;
else i++;
}
if(i==n+1){
printf("Yes\n");
break;
}
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3864kb
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: -100
Wrong Answer
time: 28ms
memory: 6584kb
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:
Yes Yes Yes Yes No Yes Yes No Yes No Yes Yes 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 Yes No No No Yes No Yes Yes No No Yes No No No No No Yes No Yes Yes Yes No Yes No Yes No Yes Yes Yes No No Yes No No Yes No No Yes No No Yes Yes Yes Yes...
result:
wrong answer 1st lines differ - expected: 'No', found: 'Yes'