QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#835000 | #9925. LR String | ucup-team5075# | WA | 36ms | 5872kb | C++14 | 897b | 2024-12-28 08:48:35 | 2024-12-28 08:48:35 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=5e5+9;
char S[N],T[N];
int nxt[N][3],n,m;
int head[3];
bool check()
{
scanf("%s",T+1);m=strlen(T+1);
if(T[1]=='R'&&S[1]!='R') return 0;
if(T[m]=='L'&&S[n]!='L') return 0;
int nw=0;
for(int i=1;i<=n;i++)
{
if(T[i]=='L'&&T[i+1]=='R') nw=nxt[nw][2],i++;
else if(T[i]=='L') nw=nxt[nw][0];
else if(T[i]=='R') nw=nxt[nw][1];
}
return (nw!=n+1);
}
void work()
{
scanf("%s",S+1);n=strlen(S+1);
for(int i=0;i<3;i++) head[i]=nxt[n+1][i]=n+1;
for(int i=n;i>=0;i--)
{
for(int j=0;j<3;j++) nxt[i][j]=head[j];
if(S[i]=='L') head[0]=i;
if(S[i]=='R') head[1]=i;
if(S[i]=='L'&&S[i+1]=='R') head[2]=i;
}
int Q;scanf("%d",&Q);
while(Q--) puts(check()?"YES":"NO");
}
signed main()
{
int T;scanf("%d",&T);
while(T--) work();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 5676kb
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: 5872kb
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 NO YES YES YES YES NO NO NO YES YES NO YES NO NO NO NO YES YES YES YES YES YES YES YES YES YES YES NO NO YES NO NO NO NO NO NO NO NO YES NO NO NO NO NO NO NO NO YES NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO YES YES NO YES YES YES NO NO NO NO NO NO NO NO YES YES NO NO NO NO NO YES ...
result:
wrong answer 41st lines differ - expected: 'YES', found: 'NO'