QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#169114 | #7104. Halting Problem | megrezbunny# | WA | 21ms | 6496kb | C++17 | 2.4kb | 2023-09-09 12:38:21 | 2023-09-09 12:38:21 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e4+5;
int T;
int n;
bool vis[MAXN][256];
char buf[10];
struct opr
{
int type; //0: add, 1: >=jump. 2: ==jump.
int v1, v2, x; // >=x, goto v1; <= x-1, goto v2.
// ==x, goto v1; != x, goto v2.
}a[MAXN];
int main()
{
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
memset(vis, 0, sizeof(bool)*(256)*(n+5));
for(int i = 1; i <= n; ++i)
{
scanf(" %s",buf);
if(buf[0] == 'a')
{
scanf("%d",&a[i].x);
a[i].type = 0;
}
else if(buf[1] == 'e')
{
a[i].type = 2;
scanf("%d%d",&a[i].x,&a[i].v1);
a[i].v2 = i+1;
}
else if(buf[1] == 'n')
{
a[i].type = 2;
scanf("%d%d",&a[i].x,&a[i].v2);
a[i].v1 = i+1;
}
else if(buf[1] == 'l')
{
a[i].type = 1;
scanf("%d%d",&a[i].x,&a[i].v2);
a[i].v1 = i+1;
}
else
{
a[i].type = 1;
scanf("%d%d",&a[i].x,&a[i].v1);
a[i].v2 = i+1;
}
}
int nowu = 1, nows = 0;
bool flag = false;
while(1)
{
if(nowu == n+1)
{
flag = true;
break;
}
else if(vis[nowu][nows])
{
flag = false;
break;
}
vis[nowu][nows] = true;
if(a[nowu].type == 0)
{
nows = (nows + a[nowu].x) % 256;
nowu = nowu + 1;
}
else if(a[nowu].type == 1)
{
if(nows >= a[nowu].x)
{
nowu = a[nowu].v1;
}
else nowu = a[nowu].v2;
}
else
{
if(nows == a[nowu].x)
{
nowu = a[nowu].v1;
}
else nowu = a[nowu].v2;
}
}
if(flag) printf("Yes\n");
else printf("No\n");
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3856kb
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: 21ms
memory: 6496kb
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:
wrong answer 89th lines differ - expected: 'Yes', found: 'No'