QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#156758 | #7104. Halting Problem | ucup-team1479# | AC ✓ | 9ms | 6404kb | C++14 | 1.7kb | 2023-09-02 14:14:14 | 2023-09-02 14:52:58 |
Judging History
answer
//prepare for coding{{{
#include<bits/stdc++.h>
#define RELEASE
#ifndef RELEASE
#define FL
#define DB(...) fprintf(stderr,__VA_ARGS__)
#endif
const int N=10000;
const int V=1<<8,U=V-1;
using namespace std;
inline int Read(){
char c=getchar();
int res=0;
bool b=0;
while(c>'9'||c<'0')
b=(c=='-'),c=getchar();
while(c>='0'&&c<='9')
res=(res<<3)+(res<<1)+c-'0',c=getchar();
return b?-res:res;
}
char tmp[10];
inline int ReadS(){
char c=getchar();
int tt=0;
while(c<'a'||c>'z')
c=getchar();
while(c>='a'&&c<='z')
tmp[++tt]=c,c=getchar();
if(tmp[1]=='a')
return 0;
if(tmp[2]=='e')
return 1;
if(tmp[2]=='n')
return 2;
if(tmp[2]=='l')
return 3;
return 4;
}
inline int Add(int a,int b){
return (a+b)&U;
}
inline int MAdd(int &x,int y){
return x=(x+y)&U;
}
int n;
int op[N+10],ox[N+10],oy[N+10];
bool used[N+10][V];
//}}}
//solve{{{
inline bool Do(int x,int y){
if(x>n)
return 1;
if(used[x][y])
return 0;
used[x][y]=1;
if(!op[x])
return Do(x+1,Add(y,ox[x]));
if(op[x]==1)
return Do(y==ox[x]?oy[x]:x+1,y);
if(op[x]==2)
return Do(y!=ox[x]?oy[x]:x+1,y);
if(op[x]==3)
return Do(y<ox[x]?oy[x]:x+1,y);
return Do(y>ox[x]?oy[x]:x+1,y);
}
inline void Solve(){
n=Read();
for(int i=1;i<=n;++i){
for(int j=0;j<V;++j)
used[i][j]=0;
op[i]=ReadS();
ox[i]=Read();
if(op[i])
oy[i]=Read();
}
printf(Do(1,0)?"Yes":"No");
puts("");
}
//}}}
//main{{{
int main(){
#ifdef FL
freopen(".in","r",stdin);
freopen(".out","w",stdout);
#endif
int T=Read()+1;
while(--T)
Solve();
return 0;
}
//}}}
//《象》曰:泽灭木,大过。君子以独立不惧,遁世无
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 3740kb
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: 6404kb
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