QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#325798#8224. Caught in the Middlewinter20200 0ms3580kbC++141.1kb2024-02-11 23:19:132024-02-11 23:19:14

Judging History

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

  • [2024-02-11 23:19:14]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:3580kb
  • [2024-02-11 23:19:13]
  • 提交

answer

#include <iostream>
#include <cstring>

using namespace std;

int n;
string s;

bool check(string t) {
    for (int i = 0; i < t.size() - 1; i ++ )
        if (t[i] == t[i + 1]) return false;
    return true;
}

void solve() {
    cin >> n >> s;
    if (n == 1 || s[0] == 'L' || s[n - 1] == 'R') {
        puts("Alice");
        return;
    }
    if (check(s)) puts("Bob");
    else {
        int pos = -1;
        for (int i = 0; i < n - 1; i ++ )
            if (s[i] == s[i + 1] && s[i] == 'R') pos = i;
        if (pos != -1) {
            if (check(s.substr(pos + 1))) {
                puts("Alice");
                return;
            }
        }
        pos = -1;
        for (int i = 0; i < n - 1; i ++ )
            if (s[i] == s[i + 1] && s[i] == 'L') {
                pos = i + 1;
                break;
            }
        if (pos != -1) {
            if (check(s.substr(0, pos))) {
                puts("Alice");
                return;
            }
        }
        puts("Bob");
        return;
    }
}

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

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 23
Accepted
time: 0ms
memory: 3536kb

input:

20
10
RLRRRRLLRR
10
LRLLLLRRLR
6
RLRLRL
10
LLRLRRRRLR
6
LRRLLL
3
RLR
5
LLRRR
6
RRRRRL
9
LRRRLRRLR
1
R
10
RRRLLRRLLL
6
LRLLLR
9
LLRLRLRLR
7
RRRRLRR
2
LL
10
RRRLLRRLRR
2
RL
7
RRLRRLR
3
LLR
10
LLRLRRRLLR

output:

Alice
Alice
Bob
Alice
Alice
Alice
Alice
Alice
Alice
Alice
Bob
Alice
Alice
Alice
Alice
Alice
Bob
Alice
Alice
Alice

result:

ok 20 lines

Test #2:

score: -23
Wrong Answer
time: 0ms
memory: 3580kb

input:

20
7
LRLLRRR
8
LRLRLRRR
3
RLL
10
RLRLRLRLRL
10
RLRLRLRLRL
6
RLLLRL
10
RLRLRLRLLL
5
RLRRR
2
LL
10
RRRRLRLRLL
7
LLRRLLR
3
LRR
10
RRRRRLLLLL
10
RLRRRLRLRR
2
LR
6
RRLLLL
4
RRLR
10
LRLRLLRLRR
4
LRLL
10
RRLLRRRLLL

output:

Alice
Alice
Alice
Bob
Bob
Alice
Alice
Alice
Alice
Bob
Alice
Alice
Bob
Alice
Alice
Bob
Alice
Alice
Alice
Bob

result:

wrong answer 10th lines differ - expected: 'Alice', found: 'Bob'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%