QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#865701#9925. LR StringjmnbTL 4ms21228kbC++201.7kb2025-01-21 21:15:472025-01-21 21:15:58

Judging History

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

  • [2025-01-21 21:15:58]
  • 评测
  • 测评结果:TL
  • 用时:4ms
  • 内存:21228kb
  • [2025-01-21 21:15:47]
  • 提交

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;
        memset(w,0,sizeof(w));
        memset(ans,0,sizeof(ans));
        for(int j=1;j<=m;j++) {
            cin>>s;
            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();) {
                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
    */
}

詳細信息

Test #1:

score: 100
Accepted
time: 4ms
memory: 21228kb

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
Time Limit Exceeded

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: