QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#865633 | #9925. LR String | jmnb | WA | 86ms | 7836kb | C++20 | 1.1kb | 2025-01-21 20:37:38 | 2025-01-21 20:37:38 |
Judging History
answer
#include <iostream>
#include<bits/stdc++.h>
#define N 200005
using namespace std;
struct stru
{
int head,end;
};
int a[N],T,n,fl,ans;
void read(int &x)
{
x=0;
int f=1;
char c=getchar();
while (c<'0' || c>'9')
{
if (c=='-') f=-1;
c=getchar();
}
while (c>='0' && c<='9')
{
x=x*10+c-'0';
c=getchar();
}
x*=f;
return;
}
char str[100001];
string s[100001];
int lenstr=0,lens[100001],nxt[100001],cnt[100001];
signed main ()
{
scanf("%d",&T);
while (T--)
{
scanf("%s",str);
lenstr=strlen(str);
scanf("%d",&n);
for (int i=1; i<=n; i++)
{
cin>>s[i];
lens[i]=size(s[i]);
}
for (int i=1; i<=n+1; i++)
{
nxt[i]=i+1;
cnt[i]=0;
}
for (int i=0; i<lenstr; i++)
for (int j=1; j<=n; j=nxt[j])
{
if (str[i]==s[j][cnt[j]])
if (++cnt[j]==lens[j]) nxt[j]=nxt[nxt[j]];
//cout<<"1";
}
for (int i=1; i<=n; i++)
if(str[0]=='L'&&s[i][0]=='R') {
cout<<"No";
}
else if(str[lenstr-1]=='R'&&s[i][s[i].size()-1]=='L') {
cout<<"No";
}
else if (cnt[i]==lens[i]) printf("YES\n");
else printf("NO\n");
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 7836kb
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: 86ms
memory: 6992kb
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 NO YES NO NoYES NO YES NO NoNoNoYES NO NO YES NoNoNO NO YES NO YES NO YES NO YES NO YES NO YES NoNoYES NoNoNoNoNoNO YES NO YES NoNoNoNO NoNoNoNoYES NoNO NO YES YES NoNoNoNoNoNoNoNoNoYES YES NO YES YES NO YES NoNoNoNoYES NO NO YES YES NO NO NO NO NoNO YES NoYES YES YES NoNoYES NO NO YES NoNO NoYE...
result:
wrong answer 2nd lines differ - expected: 'YES', found: 'NO'