QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#175870#7104. Halting Problemucup-team1430#AC ✓64ms14036kbC++202.0kb2023-09-11 03:40:112023-09-11 03:40:11

Judging History

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

  • [2023-09-11 03:40:11]
  • 评测
  • 测评结果:AC
  • 用时:64ms
  • 内存:14036kb
  • [2023-09-11 03:40:11]
  • 提交

answer

#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define ld long double
#define pb push_back
#define sws cin.tie(0)->sync_with_stdio(false);
#define endl '\n'

using namespace std;

const int N = 2e5+10;
const int MOD = 256;
// const ll MOD = 998244353;
// const ll MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;

#define vp vector<point>
#define ld long double
const ld EPS = 1e-6;
const ld PI = acos(-1);

bool isPowerOfTwo(int x) { return x && (!(x&(x-1))); }
int flog2(int x) { return 32-1-__builtin_clz(x); }

int32_t main()
{
    #ifndef LOCAL
    sws;
    #endif

    int t; cin >> t;
    while (t--) {
        int n; cin >> n;
        vector<string> op(n);
        vector<pair<int, int>> args(n);
        for (int i=0;i<n;i++) {
            cin >> op[i];
            if (op[i] == "add") {
                int v; cin >> v;
                args[i] = {v, -1};
            } else {
                int v, k; cin >> v >> k;
                k --;
                args[i] = {v, k};
            }
        }

        bool ans = false;
        vector<vector<int>> seen(n, vector<int>(256, false));
        int linha = 0, r = 0;
        while (seen[linha][r] == false) {
            seen[linha][r] = true;
            auto [v, k] = args[linha];
            if (op[linha] == "add") {
                r = (r + v) % MOD; linha ++;
            } else if (op[linha] == "beq") {
                if (r == v) linha = k;
                else linha ++;
            } else if (op[linha] == "bne") {
                if (r != v) linha = k;
                else linha ++;
            } else if (op[linha] == "blt") {
                if (r < v) linha = k;
                else linha ++;
            } else if (op[linha] == "bgt") {
                if (r > v) linha = k;
                else linha ++;
            }

            if (linha == n) { ans = true; break; }
        }

        cout << (ans ? "Yes":"No") << endl;
    }

    return 0;
}

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

详细

Test #1:

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

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: 64ms
memory: 14036kb

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