QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#865750#9925. LR Stringx998244353xTL 96ms5840kbC++201.3kb2025-01-21 21:45:212025-01-21 21:45:22

Judging History

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

  • [2025-01-21 21:45:22]
  • 评测
  • 测评结果:TL
  • 用时:96ms
  • 内存:5840kb
  • [2025-01-21 21:45:21]
  • 提交

answer

#include <iostream>
#include <cstdio>
#include <vector>
#define N 500005
using namespace std;
struct stru
{
	int id,len;
};
vector <stru> sv[N],strv;
int cnt[N],T,n,cnt_,fll,flr;
bool flL[N],flR[N];
string str;
signed main ()
{ 
	cin>>T;
	while (T--)
	{
		cin>>str;
		str+='#';
		strv.clear();
		cnt_=1;
		for (int i=1; i<str.size(); i++)
			if (str[i-1]!=str[i])
			{
				strv.push_back((stru){(str[i-1]=='R'),cnt_});
				cnt_=1;
			}
			else cnt_++;
		fll=(str[0]=='R');
		flr=(str[str.size()-2]=='L');
		cin>>n;
		for (int i=1; i<=n; i++)
		{
			cin>>str;
			str+='#';
			sv[i].clear();
			cnt_=1;
			for (int j=1; j<str.size(); j++)
				if (str[j-1]!=str[j])
				{
					sv[i].push_back((stru){(str[j-1]=='R'),cnt_});
					cnt_=1;
				}
				else cnt_++;
			flL[i]=(str[0]=='L');
			flR[i]=(str[str.size()-2]=='R');
			cnt[i]=0;
		}
		sv[0].clear();
		sv[0].push_back((stru){2,0});
		for (int i=0; i<strv.size(); i++)
		{
			cnt_=0;
			for (int j=1; j<=n; j++)
				if (cnt[j]!=sv[j].size())
					if (strv[i].id==sv[j][cnt[j]].id)
					{
						if (strv[i].len>=sv[j][cnt[j]].len) cnt[j]++;
						else sv[j][cnt[j]].len-=strv[i].len;
					}
		}
		for (int i=1; i<=n; i++)
			if (cnt[i]==sv[i].size() && (fll || flL[i]) && (flr || flR[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: 2ms
memory: 5840kb

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: 0
Accepted
time: 96ms
memory: 3584kb

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
YES
YES
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
YES
YES
YES
YES
YES
NO
NO
NO
NO
YES
NO
NO
YES
YES
YES
NO
NO
NO
NO...

result:

ok 356450 lines

Test #3:

score: -100
Time Limit Exceeded

input:

2
RRLRLLLRLRLRLRLLLLRRLLLRLRRLLLLLLRRRRRLRLRLRLLLLRRRLLRLRRLLRRRRRLLRLLRLLLLRLLLLRLLRRRRLRLLRRLRRRLLRRRLLLRLLRRLRLRRRRLRRLRRRLRLRLLLRLRRLRLRRRRRRLRRRRRLLLRLLLLRLRRRLRLRLLLRLRLLLLRLRRLRRLLRLRLRRLLLRRRLLLLLLLRLRRLLLLLRLRRLRLRLRRRLLRLLRLLRRLRRLLRLRLRLRLRRLRRRLLLRLLRLRLRRLRRRLLRRRRRRRRLLRLLRRLLRRLLLLRLR...

output:


result: