QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#855207#9925. LR StringyuanruiqiRE 26ms3872kbC++14935b2025-01-12 16:12:302025-01-12 16:12:30

Judging History

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

  • [2025-01-12 16:12:30]
  • 评测
  • 测评结果:RE
  • 用时:26ms
  • 内存:3872kb
  • [2025-01-12 16:12:30]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
constexpr int maxn = 100000 + 10;
int p[maxn][2];
void solve()
{
    string s;
    cin >> s;
    int n = s.size();
    p[n][0] = p[n][1] = n;
    for (int i=n-1;i>=0;--i)
    {
        p[i][0] = p[i + 1][0];
        p[i][1] = p[i + 1][1];
        p[i][s[i] == 'R'] = i;
    }
    int m;
    cin >> m;
    while (m--)
    {
        string t;
        cin >> t;
        if (t[0] == 'R' && s[0] == 'L' || t.back() == 'L' && s.back() == 'R') cout << "NO\n";
        else
        {
            int x = -1;
            for (char c : t)
            {
                x = p[x + 1][c == 'R'];
                if (x == n) break;
            }
            cout << (x == n ? "NO\n" : "YES\n");
        }
    }
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin >> t;
    while (t--) solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3872kb

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: 26ms
memory: 3580kb

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
Runtime Error

input:

2
RRLRLLLRLRLRLRLLLLRRLLLRLRRLLLLLLRRRRRLRLRLRLLLLRRRLLRLRRLLRRRRRLLRLLRLLLLRLLLLRLLRRRRLRLLRRLRRRLLRRRLLLRLLRRLRLRRRRLRRLRRRLRLRLLLRLRRLRLRRRRRRLRRRRRLLLRLLLLRLRRRLRLRLLLRLRLLLLRLRRLRRLLRLRLRRLLLRRRLLLLLLLRLRRLLLLLRLRRLRLRLRRRLLRLLRLLRRLRRLLRLRLRLRLRRLRRRLLLRLLRLRLRRLRRRLLRRRRRRRRLLRLLRRLLRRLLLLRLR...

output:


result: