QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#156374 | #7104. Halting Problem | ucup-team1477# | AC ✓ | 9ms | 6460kb | C++14 | 1.5kb | 2023-09-02 13:29:46 | 2023-09-02 14:50:21 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
int n=0,f=1,ch=getchar();
while(ch<'0'||ch>'9')
{
if(ch=='-')f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9')
{
n=n*10+ch-'0';
ch=getchar();
}
return n*f;
}
char s[10005];
int qo[10005],qx[10005],qy[10005];
bool vis[10005][256];
int n;
bool dfs(int x,int y)
{
if(x==n+1)return true;
if(vis[x][y])return false;
vis[x][y]=true;
if(qo[x]==1)
{
return dfs(x+1,(y+qx[x])%256);
}
else if(qo[x]==2)
{
if(y==qx[x])return dfs(qy[x],y);
else return dfs(x+1,y);
}
else if(qo[x]==3)
{
if(y!=qx[x])return dfs(qy[x],y);
else return dfs(x+1,y);
}
else if(qo[x]==4)
{
if(y<qx[x])return dfs(qy[x],y);
else return dfs(x+1,y);
}
else
{
if(y>qx[x])return dfs(qy[x],y);
else return dfs(x+1,y);
}
return false;
}
int main()
{
int t,x,y;
t=read();
for(int greg=1;greg<=t;greg++)
{
n=read();
for(int i=1;i<=n;i++)
{
for(int j=0;j<=255;j++)vis[i][j]=false;
}
for(int i=1;i<=n;i++)
{
scanf("%s",s+1);
if(s[2]=='d')
{
x=read();
qo[i]=1;
qx[i]=x;
}
else if(s[2]=='e')
{
qo[i]=2;
qx[i]=read();
qy[i]=read();
}
else if(s[2]=='n')
{
qo[i]=3;
qx[i]=read();
qy[i]=read();
}
else if(s[2]=='l')
{
qo[i]=4;
qx[i]=read();
qy[i]=read();
}
else if(s[2]=='g')
{
qo[i]=5;
qx[i]=read();
qy[i]=read();
}
}
if(dfs(1,0))printf("Yes\n");
else printf("No\n");
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
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: 0
Accepted
time: 9ms
memory: 6460kb
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