QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#169122#7104. Halting ProblemTjan#AC ✓16ms3872kbC++172.0kb2023-09-09 12:46:002023-09-09 12:46:01

Judging History

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

  • [2023-09-09 12:46:01]
  • 评测
  • 测评结果:AC
  • 用时:16ms
  • 内存:3872kb
  • [2023-09-09 12:46:00]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define For(i,a,b) for(int i=(a);i<=(b);i++)
#define Rof(i,a,b) for(int i=(a);i>=(b);i--)
#define ll long long
#define wln putchar('\n')
template<class T1,class T2> void chkmin(T1 &x,T2 y){if(y<x)x=y;}
template<class T1,class T2> void chkmax(T1 &x,T2 y){if(y>x)x=y;}
#define maxn 100005
#define mod 256

int T;
int n, m;
int t[maxn];
int op[maxn];
int val[maxn], pos[maxn];

void init()
{
    For(i, 1, n) t[i] = 0;
    return ;
}
int read()
{
    int ans = 0;
    char ch = getchar();
    for(;ch < '0' || ch > '9';ch = getchar()) ;
    for(;ch >= '0' && ch <= '9';ch = getchar()) ans = ans * 10 + ch - '0';
    return ans;
}
void Main()
{
    init();
    n = read();
    char ch;
    For(i, 1, n) {
        ch = getchar();
        while(ch != 'a' && ch != 'b') ch = getchar();
        
        if(ch == 'a') op[i] = 1, val[i] = read();
        if(ch == 'b') {
            ch = getchar();
            if(ch == 'e') op[i] = 2;
            else if(ch == 'n') op[i] = 3;
            else if(ch == 'l') op[i] = 4;
            else if(ch == 'g') op[i] = 5;
            val[i] = read();
            pos[i] = read();
        }
        
    }
    int nw = 1, v = 0;
    while(nw != n + 1) {
    	t[nw]++;
        if(t[nw] > 256) return printf("No\n"), void();
        if(op[nw] == 1) v = (v + val[nw]) % mod, nw++;
        else if(op[nw] == 2) {
            if(v == val[nw]) nw = pos[nw];
            else nw++;
        }
        else if(op[nw] == 3) {
            if(v != val[nw]) nw = pos[nw];
            else nw++;
        }
        else if(op[nw] == 4) {
            if(v < val[nw]) nw = pos[nw];
            else nw++;
        }
        else if(op[nw] == 5) {
            if(v > val[nw]) nw = pos[nw];
            else nw++;
        }
    }
    printf("Yes\n");
}
int main()
{
    T = read();
    while(T--) Main();
    return 0;
}
/*
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
*/

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 16ms
memory: 3872kb

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