QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#865633#9925. LR StringjmnbWA 86ms7836kbC++201.1kb2025-01-21 20:37:382025-01-21 20:37:38

Judging History

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

  • [2025-01-21 20:37:38]
  • 评测
  • 测评结果:WA
  • 用时:86ms
  • 内存:7836kb
  • [2025-01-21 20:37:38]
  • 提交

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;
}

詳細信息

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'