QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#865757 | #9925. LR String | jmnb | TL | 136ms | 20976kb | C++20 | 1.7kb | 2025-01-21 21:51:13 | 2025-01-21 21:51:21 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int n,m,w[500005];
string ans[500005];
int main() {
string S,s;
char now;
cin>>n;
for(int i=1;i<=n;i++) {
list<pair<string,int>> li;
cin>>S;
cin>>m;
for(int j=1;j<=m;j++) {
cin>>s;
w[j]=0;
pair<string,int> d;
d.first=s;
d.second=j;ans[j]="NO";
if(S[0]=='L'&&s[0]=='R') {
continue;
}
else if(S[S.size()-1]=='R'&&s[s.size()-1]=='L') {
continue;
}
li.push_back(d);
}
int j=0,LS=0;
now=S[0];
while(j<S.size()) {
LS=j;
while(S[j]==now) {
j++;
}
LS=j-LS;
now=S[j-1];
for(auto it=li.begin();it!=li.end();it++) {
string s1=(*it).first;
int p=(*it).second;
int cnt=1;
while(s1[w[p]]==now&&cnt<=LS) {
w[p]++;
cnt++;
//cout<<"1";
}
if(w[p]==s1.size()) {
ans[p]="YES";
//it=li.erase(it);
//cout<<s1<<" "<<ans[p]<<endl;
}
else {
//it++;
}
// cout<<s1<<" "<<s1.size()<<" "<<w[p]<<endl;
}
now=S[j];
}
for(int j=1;j<=m;j++) {
cout<<ans[j]<<endl;
}
}
/*
1
RRLLRRLL
4
LLLLL
LLR
LRLR
R
*/
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 20976kb
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: 136ms
memory: 20916kb
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...