QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#865637 | #9925. LR String | jmnb | WA | 104ms | 8008kb | C++20 | 1.1kb | 2025-01-21 20:40:41 | 2025-01-21 20:40:41 |
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"<<endl;
}
else if(str[lenstr-1]=='R'&&s[i][s[i].size()-1]=='L') {
cout<<"No"<<endl;
}
else if (cnt[i]==lens[i]) printf("YES\n");
else printf("NO\n");
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 8008kb
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: 104ms
memory: 8008kb
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 No YES NO YES NO No No No YES NO NO YES No No NO NO YES NO YES NO YES NO YES NO YES NO YES No No YES No No No No No NO YES NO YES No No No NO No No No No YES No NO NO YES YES No No No No No No No No No YES YES NO YES YES NO YES No No No No YES NO NO YES YES NO NO NO NO No NO YES No YES...
result:
wrong answer 2nd lines differ - expected: 'YES', found: 'NO'