QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#361027#8287. Caught in the Middlepaoxiaomo#WA 0ms3544kbC++171.2kb2024-03-22 18:13:222024-03-22 18:13:22

Judging History

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

  • [2024-03-22 18:13:22]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3544kb
  • [2024-03-22 18:13:22]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
void solve()
{
    int n;
    string s;
    cin >> n >> s;
    int t = count(s.begin(), s.end(), 'L');
    if (t == 0 || t == n)
    {
        cout << "Alice" << endl;
        return;
    }
    int ll = -1, rr = -1;
    for (int i = 0; i < n; i++)
    {
        if (s[i] == 'L')
        {
            ll = i + 1;
            break;
        }
    }
    for (int i = n - 1; i >= 0; i--)
    {
        if (s[i] == 'R')
        {
            rr = i + 1;
            break;
        }
    }
    if (ll == 1 || rr == n)
    {
        cout << "Alice" << endl;
        return;
    }
    if (ll > rr)
    {
        if (n & 1)
        {
            cout << "Alice" << endl;
        }
        else
        {
            cout << "Bob" << endl;
        }
        return;
    }
    int tim = ll - 1 + n - rr;
    cout << ll << " " << rr << endl;
    if (tim & 1)
    {
        cout << "Alice" << endl;
    }
    else
    {
        cout << "Bob" << endl;
    }
}
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int T = 1;
    cin >> T;
    while (T--)
        solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3544kb

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
2 5
Bob
Alice
Alice
Alice
Alice
Bob
Alice
Alice
4 7
Bob
Alice
Alice
Alice
Alice
Alice
Bob
Alice
Alice
Alice

result:

wrong answer 3rd lines differ - expected: 'Bob', found: '2 5'