QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#865072 | #9925. LR String | fanchuanyu | WA | 101ms | 3712kb | C++14 | 705b | 2025-01-21 14:32:22 | 2025-01-21 14:32:29 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int a[500005];
int nxt[500005][2];
void solve() {
string s;
cin >> s;
int n = s.size();
s = ' ' + s;
nxt[n + 1][0] = nxt[n + 1][1] = n + 1;
for (int i = n; i; i--) {
nxt[i][0] = nxt[i + 1][0];
nxt[i][1] = nxt[i + 1][1];
if (s[i] == 'L')
nxt[i][0] = i;
else
nxt[i][1] = i;
}
int q;
cin >> q;
while (q--) {
int pos = 0;
string t;
cin >> t;
bool ok = 1;
for (char c : t) {
pos = nxt[pos + 1][(c == 'R')];
if (pos == n + 1) {
ok = 0;
break;
}
}
cout << (ok ? "YES" : "NO") << '\n';
}
return ;
}
signed main() {
int T;
cin >> T;
while (T--) {
solve();
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3712kb
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
Wrong Answer
time: 101ms
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 YES YES YES YES YES YES YES YES YES YES NO YES YES YES NO NO YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES NO YES YES YES NO NO NO NO NO NO YES YES YES YES NO NO YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES NO YES YES YES N...
result:
wrong answer 5th lines differ - expected: 'NO', found: 'YES'