QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#157341#7104. Halting Problemucup-team1448#AC ✓21ms11556kbC++142.4kb2023-09-02 15:13:342023-09-02 15:13:35

Judging History

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

  • [2023-09-02 15:13:35]
  • 评测
  • 测评结果:AC
  • 用时:21ms
  • 内存:11556kb
  • [2023-09-02 15:13:34]
  • 提交

answer

//#define dxx
#ifdef dxx
#define dbg(...) fprintf(stderr,__VA_ARGS__)
#define dex(a) dbg(#a"=%lld onL%d infun %s\n",a,__LINE__,__FUNCTION__)
#include<cstdlib>
#define pause sys##tem("pause")
#define _GLIBCXX_DEBUG
#endif

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>

using ll=long long;
using std::max;
using std::min;
template<class T> void cmax(T&a,T b){a=max(a,b);}
template<class T> void cmin(T&a,T b){a=min(a,b);}

namespace xm{
    struct NODE{
        int op,x,y;
    } pro[10005];
    int vis[10005][256];
    void _(int tim){
        int N;

        scanf("%d",&N);
        for(int i=1;i<=N;++i){
            char op[10];
            scanf("%s",op);
            if(*op=='a'){ //add
                pro[i].op=0;
                scanf("%d",&pro[i].x);
            }else if(op[2]=='q'){ //beq
                pro[i].op=1;
                scanf("%d%d",&pro[i].x,&pro[i].y);
            }else if(op[2]=='e'){ //bne
                pro[i].op=2;
                scanf("%d%d",&pro[i].x,&pro[i].y);
            }else if(op[1]=='l'){ //blt
                pro[i].op=3;
                scanf("%d%d",&pro[i].x,&pro[i].y);
            }else if(op[1]=='g'){ //bgt
                pro[i].op=4;
                scanf("%d%d",&pro[i].x,&pro[i].y);
            }
        }

        int r=0,ip=1;
        for(;;){
            if(ip==N+1){
                puts("Yes");
                break;
            }
            if(vis[ip][r]==tim){
                puts("No");
                break;
            }
            vis[ip][r]=tim;
            switch(pro[ip].op){
            case 0: //add
                r=(r+pro[ip].x)%256;
                ++ip;
                break;
            case 1: // beq
                if(r==pro[ip].x) ip=pro[ip].y;
                else ++ip;
                break;
            case 2: // bne
                if(r!=pro[ip].x) ip=pro[ip].y;
                else ++ip;
                break;
            case 3: // blt
                if(r<pro[ip].x) ip=pro[ip].y;
                else ++ip;
                break;
            case 4: // bgt
                if(r>pro[ip].x) ip=pro[ip].y;
                else ++ip;
                break;
            }
        }
    }
}

int main(){
    int t;
    scanf("%d",&t);
    for(int cas=1;cas<=t;++cas) xm::_(cas);
    return 0;
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 1628kb

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: 21ms
memory: 11556kb

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