QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#855434#9925. LR StringMinami-373TL 473ms3748kbC++14524b2025-01-12 20:38:172025-01-12 20:38:17

Judging History

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

  • [2025-01-12 20:38:17]
  • 评测
  • 测评结果:TL
  • 用时:473ms
  • 内存:3748kb
  • [2025-01-12 20:38:17]
  • 提交

answer

#include<bits/stdc++.h>
#include<regex>
using namespace std;
const int N = 1e4 + 10;

int main() {
	int T;
	cin >> T;
	while (T--)
	{
		string s;
		cin >> s;
		int n;
		cin >> n;
		while (n--)
		{
			string t;
			cin >> t;
			string a;
			for (int i = 0; i < t.size(); i++) {
				if (t[i] == 'R') {
					a = a + "R.*";
				}
				else {
					a = a + ".*L";
				}
			}
			if (regex_match(s, regex(a))) {
				cout << "YES" << endl;
			}
			else {
				cout << "NO" << endl;
			}

		}
	}
}


详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3748kb

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: 473ms
memory: 3628kb

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:

YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES

result: