QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#90051#5854. Bot TrustChatGPT20 ✓4ms3344kbC++231.1kb2023-03-22 03:17:562023-03-22 03:17:59

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-22 03:17:59]
  • 评测
  • 测评结果:20
  • 用时:4ms
  • 内存:3344kb
  • [2023-03-22 03:17:56]
  • 提交

answer

#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
    int T;
    cin >> T;
    for (int t = 1; t <= T; ++t) {
        int N;
        cin >> N;
        vector<pair<char, int>> buttons(N);
        for (int i = 0; i < N; ++i) {
            cin >> buttons[i].first >> buttons[i].second;
        }

        int time = 0;
        int time_O = 0, time_B = 0;
        int pos_O = 1, pos_B = 1;
        for (int i = 0; i < N; ++i) {
            char robot = buttons[i].first;
            int target = buttons[i].second;
            int time_target = abs(target - (robot == 'O' ? pos_O : pos_B)) + 1;
            int time_other = (robot == 'O') ? time_B - time_O : time_O - time_B;

            if (robot == 'O') {
                time_O += max(time_target, max(0, time_other + 1));
                pos_O = target;
            } else {
                time_B += max(time_target, max(0, time_other + 1));
                pos_B = target;
            }
            time = max(time_O, time_B);
        }

        cout << "Case #" << t << ": " << time << endl;
    }
    return 0;
}

詳細信息

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 2ms
memory: 3332kb

input:

20
4 O 2 B 1 B 2 O 4
3 O 5 O 8 B 100
2 B 2 B 1
10 O 12 B 13 B 31 O 33 B 74 O 76 B 98 O 100 O 88 B 84
7 B 87 O 5 O 2 O 11 O 63 O 57 B 15
10 O 28 O 94 B 56 O 1 O 30 B 63 B 83 O 68 O 73 O 98
8 B 71 O 80 B 5 O 25 O 14 B 13 O 95 O 55
6 O 37 B 38 B 54 O 19 B 98 O 63
4 B 39 O 39 O 4 B 2
7 O 85 B 28 B 64 O ...

output:

Case #1: 6
Case #2: 100
Case #3: 4
Case #4: 117
Case #5: 163
Case #6: 290
Case #7: 274
Case #8: 101
Case #9: 77
Case #10: 188
Case #11: 152
Case #12: 10
Case #13: 182
Case #14: 1000
Case #15: 1
Case #16: 205
Case #17: 71
Case #18: 147
Case #19: 205
Case #20: 32

result:

ok 20 lines

Subtask #2:

score: 10
Accepted

Test #2:

score: 10
Accepted
time: 4ms
memory: 3344kb

input:

100
4 O 2 B 1 B 2 O 4
3 O 5 O 8 B 100
2 B 2 B 1
56 O 19 B 19 O 6 B 5 B 22 O 26 O 13 B 37 O 27 B 23 O 64 B 61 O 21 B 20 B 45 O 47 B 33 O 35 B 18 O 21 B 60 O 63 B 92 O 32 O 3 B 60 O 40 B 95 O 8 B 64 B 86 O 32 B 97 O 22 B 83 O 8 B 47 O 43 O 28 B 31 O 54 B 6 B 47 O 98 O 73 B 76 O 92 B 93 B 67 O 65 O 22 ...

output:

Case #1: 6
Case #2: 100
Case #3: 4
Case #4: 746
Case #5: 852
Case #6: 1969
Case #7: 2329
Case #8: 929
Case #9: 1837
Case #10: 1044
Case #11: 2295
Case #12: 1409
Case #13: 1460
Case #14: 1538
Case #15: 1511
Case #16: 936
Case #17: 1332
Case #18: 1772
Case #19: 1239
Case #20: 793
Case #21: 1283
Case #...

result:

ok 100 lines

Extra Test:

score: 0
Extra Test Passed