QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#407997#8287. Caught in the Middlelight_ink_dots#WA 0ms3504kbC++142.4kb2024-05-09 15:48:282024-05-09 15:48:29

Judging History

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

  • [2024-05-09 15:48:29]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3504kb
  • [2024-05-09 15:48:28]
  • 提交

answer

#include<iostream>
#include<vector>
#include<cstring>
#include<cassert>
#include<map>
using namespace std;
int n;
const int N=1e6+1000;
namespace BF{
map<string,int>vis;
int solve(string s){
    // cerr<<"?? "<<s<<endl;
    if(s.length()==0) return 0;
    if(vis.count(s)) return vis[s];
    for(int i=0;i<s.length();i++){
        if(s[i]=='R'){
            string tmp;
            for(int j=i+1;j<s.length();j++) tmp+=s[j];
            if(solve(tmp)==0) return vis[s]=1;
        }else{
            string tmp;
            for(int j=0;j<i;j++) tmp+=s[j];
            if(solve(tmp)==0) return vis[s]=1;
        }
    }
    return vis[s]=0;
}
}
string s;
string tos(int sta,int n){
    string tmp;
    for(int i=0;i<n;i++){
        if((sta>>i)&1) tmp+='R';
        else tmp+='L';
    }return tmp;
}
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 print(vector<int>a){
    for(int z:a){
        cerr<<z<<" ";
    }cerr<<endl;
}
vector<int> trans(string s){
    vector<int> 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.push_back(num_r-num_l);
            // for(int j=i;j<=j2;j++) s1+=s[j];
        }
        if(num_r<num_l){
            s1.push_back(num_r-num_l);
            // for(int j=i;j<=j2;j++) s1+=s[j];
        }
        i=j2+1;
    }
    return s1;
}
void resolve(string s){

}
void solve(){
    cin>>n;
    cin>>s;
    int sum=0;
    for(int i=0;i<s.length();i++){
        if(s[i]=='R') sum++;
        else sum--;
        if(sum<0) {cout<<"Alice\n";return ;}
    }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: 0
Wrong Answer
time: 0ms
memory: 3504kb

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:

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

result:

wrong answer 1st lines differ - expected: 'Alice', found: 'Bob'