QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#161856#7104. Halting Problemucup-team1198#AC ✓21ms4052kbC++202.1kb2023-09-03 02:21:472023-09-03 02:21:48

Judging History

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

  • [2023-09-03 02:21:48]
  • 评测
  • 测评结果:AC
  • 用时:21ms
  • 内存:4052kb
  • [2023-09-03 02:21:47]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define pii pair<int, int>
#define ld long double
#define all(a) (a).begin(), (a).end()

bitset<256> used[10'100];

void solve() {
    int n;
    cin >> n;
    vector<pair<int, pair<int, int>>> ops(n);
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        int a;
        cin >> a;
        used[i].reset();
        if (s == "add") {
            ops[i] = make_pair(0, make_pair(a, a));
        } else if (s == "beq") {
            int b;
            cin >> b;
            ops[i] = make_pair(1, make_pair(a, b));
        } else if (s == "bne") {
            int b;
            cin >> b;
            ops[i] = make_pair(2, make_pair(a, b));
        } else if (s == "blt") {
            int b;
            cin >> b;
            ops[i] = make_pair(3, make_pair(a, b));
        } else {
            int b;
            cin >> b;
            ops[i] = make_pair(4, make_pair(a, b));
        }
    }
    int i = 0, cur_r = 0;
    while (i < n && !used[i][cur_r]) {
        used[i][cur_r] = true;
        //cout << i << ' ' << cur_r << '\n';
        if (ops[i].first == 0) {
            cur_r = (cur_r + ops[i].second.first) & 255;
            ++i;
        } else if (ops[i].first == 1) {
            if (cur_r == ops[i].second.first)
                i = ops[i].second.second - 1;
            else
                ++i;
        } else if (ops[i].first == 2) {
            if (cur_r != ops[i].second.first)
                i = ops[i].second.second - 1;
            else
                ++i;
        } else if (ops[i].first == 3) {
            if (cur_r < ops[i].second.first)
                i = ops[i].second.second - 1;
            else
                ++i;
        } else {
            if (cur_r > ops[i].second.first)
                i = ops[i].second.second - 1;
            else
                ++i;
        }
    }
    if (i == n)
        cout << "Yes\n";
    else
        cout << "No\n";
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3612kb

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: 4052kb

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