QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#361193 | #8287. Caught in the Middle | paoxiaomo# | WA | 0ms | 3576kb | C++20 | 1.2kb | 2024-03-22 21:38:09 | 2024-03-22 21:38:09 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
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;
}
vector<int> is(n + 1);
for (int i = 1; i < n; i++)
{
if (s[i - 1] == 'R' && s[i] == 'L')
is[i] = is[i - 1] = 1;
}
int num = accumulate(is.begin(), is.end(), 0);
int res = n - num;
if (res & 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: 3576kb
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 Bob Alice Alice Bob Alice Alice Alice Alice Alice Bob Alice Alice Alice
result:
wrong answer 8th lines differ - expected: 'Alice', found: 'Bob'