QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#165582#7104. Halting Problem__mjjAC ✓221ms11280kbC++202.4kb2023-09-05 19:27:482023-09-05 19:27:49

Judging History

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

  • [2023-09-05 19:27:49]
  • 评测
  • 测评结果:AC
  • 用时:221ms
  • 内存:11280kb
  • [2023-09-05 19:27:48]
  • 提交

answer

#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cstdio>
#include <queue>
#include <unordered_map>
#include <set>
#include <cmath>
#include <map>
#include <stack>
#include <sstream>
#include <random>
#include <ctime>
#include <chrono>
#define ios ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define TIME cerr << 1e3 * clock() / CLOCKS_PER_SEC << " ms\n";
#define debug(x) cerr << #x << " : " << x << '\n'
#define all(v) v.begin() , v.end()
// std::mt19937 rnd(std::chrono::system_clock::now().time_since_epoch().count());

#define x first
#define y second

using namespace std;

typedef long long LL;
typedef pair<int , int> PII;

const int N = 2e5 + 5;
const int INF = 0x3f3f3f3f;
const int mod = 998244353;

int read(){
    int x = 0 , f = 1;
    char c = getchar();
    while(c < '0' || c > '9'){
        if(c == '-')f = -1;
        c = getchar();
    }
    while(c >= '0' && c <= '9'){
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}

pair<string , PII> q[N];

void solve(){
    int n;
    cin >> n;
    for(int i = 1 ; i <= n ; i ++){
        string s;
        cin >> s;
        if(s == "add"){
            int x;
            cin >> x;
            q[i] = {s , {x , 0}};
        }else{
            int v , k;
            cin >> v >> k;
            q[i] = {s , {v , k}};
        }
    }
    int pos = 1 , cnt = 0 , val = 0;
    while(true){
        string s = q[pos].x;
        int a = q[pos].y.x , b = q[pos].y.y;
        if(s == "add"){
            pos ++;
            val = (val + a) % 256;
        }else if(s == "beq"){
            if(val == a)pos = b;
            else pos ++;
        }else if(s == "bne"){
            if(val != a)pos = b;
            else pos ++;
        }else if(s == "blt"){
            if(val < a)pos = b;
            else pos ++;
        }else{
            if(val > a)pos = b;
            else pos ++;
        }
        cnt ++;
        if(pos == n + 1)break;
        if(cnt >= n * 256)break;
    }
    if(pos == n + 1)puts("Yes");
    else puts("No");
}

int main(){
    int T;
    cin >> T;
    while(T --){
        solve();
    }
    return 0;
}
/* stuff you should look for
 * int overflow, array bounds
 * special cases (n=1?)
 * do smth instead of nothing and stay organized
 * WRITE STUFF DOWN
 * DON'T GET STUCK ON ONE APPROACH
 */

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

詳細信息

Test #1:

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

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: 221ms
memory: 11280kb

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