QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#160064 | #7104. Halting Problem | ucup-team1447# | TL | 14ms | 31496kb | C++14 | 1.5kb | 2023-09-02 19:22:22 | 2023-09-02 19:22:22 |
Judging History
answer
#include <stdio.h>
#include <array>
#include <random>
#include <queue>
std::mt19937_64 rng(0x3d03d);
#include <math.h>
#include <time.h>
#include <assert.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <set>
#define ld(x) printf("%lld\n",x)
#define int long long
using std::vector;
using vi=vector<int>;
using pi=std::pair<int,int>;
using vpi=vector<pi>;
#define x first
#define y second
inline int min(int a,int b){return a>b?b:a;}
inline int max(int a,int b){return a<b?b:a;}
inline int read()
{
int num=0,f=1;char c=getchar();
while(c<48||c>57){if(c=='-')f=-1;c=getchar();}
while(c>47&&c<58)num=num*10+(c^48),c=getchar();
return num*f;
}
int cmd[1000005],val[1000005],to[1000005];
bool g[100005][256];
signed main()
{
int T=read();while(T--)
{
int n=read();
for(int i=1;i<=n;i++)
{
memset(g[i],0,sizeof(g));
char s[9];scanf("%s",s);
if(s[0]=='a')cmd[i]='a',val[i]=read();
else cmd[i]=s[1],val[i]=read(),to[i]=read();
}
int C=1,D=0;
while(1)
{
if(C==n+1)goto yes;
if(g[C][D])goto no;
g[C][D]=1;
if(cmd[C]=='a')D=(D+val[C])%256,C++;
else if(cmd[C]=='g')C=(D>val[C])?to[C]:C+1;
else if(cmd[C]=='l')C=(D<val[C])?to[C]:C+1;
else if(cmd[C]=='e')C=(D==val[C])?to[C]:C+1;
else if(cmd[C]=='n')C=(D!=val[C])?to[C]:C+1;
}
yes:puts("Yes");continue;
no:puts("No");
}
fprintf(stderr,"%.12lf\n",1.*clock()/CLOCKS_PER_SEC);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 14ms
memory: 31496kb
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
Time Limit Exceeded
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...