QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#407929 | #8287. Caught in the Middle | light_ink_dots# | WA | 1ms | 3592kb | C++14 | 922b | 2024-05-09 14:55:01 | 2024-05-09 14:55:03 |
Judging History
answer
#include<iostream>
#include<cstring>
using namespace std;
int n;
const int N=1e6+1000;
string s;
int solver(const string &s){
if(s.size()==0) return 0;
if(s.size()==1) return 1;
if(s[0]=='L') return 1;
if(s.back()=='R') return 1;
string s1;
int i=0;
while(i<s.length()){
int j1=i,j2=0;
while(j1+1<s.length()&&s[j1+1]=='R') j1++;
j2=j1+1;
while(j2+1<s.length()&&s[j2+1]=='L') j2++;
int num_r=j1-i+1;
int num_l=j2-j1;
if(num_r>num_l) s1+='R';
if(num_r<num_l) s1+='L';
i=j2+1;
}
return solver(s1);
}
void solve(){
cin>>n;
cin>>s;
if(solver(s)) cout<<"Alice\n";
else cout<<"Bob\n";
}
int main(){
ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
int T;cin>>T;
while(T--){
solve();
}
// cin>>n;
}
/*
3
5
LRLLR
6
RLRLRL
1
L
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3488kb
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: -100
Wrong Answer
time: 0ms
memory: 3592kb
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 Alice Alice Alice Alice Bob
result:
wrong answer 10th lines differ - expected: 'Alice', found: 'Bob'