QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#160068#7104. Halting Problemucup-team1447#AC ✓14ms11140kbC++141.5kb2023-09-02 19:23:452023-09-02 19:23:47

Judging History

你现在查看的是最新测评结果

  • [2023-09-02 19:23:47]
  • 评测
  • 测评结果:AC
  • 用时:14ms
  • 内存:11140kb
  • [2023-09-02 19:23:45]
  • 提交

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[i]));
    		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;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 7892kb

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: 14ms
memory: 11140kb

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