QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#848296 | #9925. LR String | isWFnoya# | WA | 36ms | 7736kb | C++23 | 952b | 2025-01-08 18:49:47 | 2025-01-08 18:49:48 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=4e5+10;
typedef long long ll;
typedef pair<ll,ll> PII;
int n,m,k;
ll a[N],b[N],c[N];
// char s[N];
char s[N],s2[N];
vector<int> e[N];
int ne[N][2];
bool check(){
int now=0;
for(int j=1;j<=k;j++){
if(s2[j]=='L'){
now=ne[now][0];
}else{
now=ne[now][1];
}
if(now==n+1){
return false;
}
}
return true;
}
void __(){
scanf("%s",s+1);
n=strlen(s+1);
scanf("%d",&m);
int num1=n+1,num2=n+1;
for(int i=n;i>=0;i--){
ne[i][0]=num1;
ne[i][1]=num2;
if(s[i]=='L') num1=i;
else num2=i;
}
while(m--){
scanf("%s",s2+1);
k=strlen(s2+1);
if(check()) puts("YES");
else puts("NO");
}
}
int main(){
int _=1;
cin>>_;
while(_--){
__();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 7736kb
input:
2 RRLLRRLL 4 LLLLL LLR LRLR R RLLLLLL 3 LLLLL RL RRL
output:
NO YES NO YES YES YES NO
result:
ok 7 lines
Test #2:
score: -100
Wrong Answer
time: 36ms
memory: 5688kb
input:
100000 RRLLR 4 R R R R LRLLL 6 R L L L L R RLLRR 1 L LRLLL 3 R L L RLRRL 2 LRRRR RRRL LRLRR 2 L R RRLRL 4 RLRLR RLLL LR RLL RLRLL 8 R R R L L L R L RLLRR 7 R LL RL R L L L LLRLR 2 L R RRRRL 1 RLLLR RRLLL 2 L L RLLRL 1 RLLRL LRLLL 5 RLRLL RLLLR RRRRL LLRRR RLLRR LRLLL 3 RRLL R RL LLRRL 3 L R LLLRR RR...
output:
YES YES YES YES YES YES YES YES YES YES YES YES YES YES NO YES YES YES NO NO YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES NO YES YES YES NO NO NO NO NO NO YES YES YES YES NO NO YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES NO YES YES YES N...
result:
wrong answer 5th lines differ - expected: 'NO', found: 'YES'