QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#865743 | #9925. LR String | x998244353x | WA | 86ms | 5836kb | C++20 | 1.3kb | 2025-01-21 21:40:13 | 2025-01-21 21:40:23 |
Judging History
answer
#include <iostream>
#include <cstdio>
#include <vector>
#define N 500005
using namespace std;
struct stru
{
int id,len;
};
vector <stru> sv[N],strv;
int cnt[N],c[N],T,n,cnt_,fll,flr;
bool flL[N],flR[N];
string str;
signed main ()
{
cin>>T;
while (T--)
{
cin>>str;
str+='#';
strv.clear();
cnt_=1;
for (int i=1; i<str.size(); i++)
if (str[i-1]!=str[i])
{
strv.push_back((stru){(str[i-1]=='R'),cnt_});
cnt_=1;
}
else cnt_++;
fll=(str[0]=='R');
flr=(str[str.size()-2]=='L');
cin>>n;
for (int i=1; i<=n; i++)
{
cin>>str;
str+='#';
sv[i].clear();
cnt_=1;
for (int j=1; j<str.size(); j++)
if (str[j-1]!=str[j])
{
sv[i].push_back((stru){(str[j-1]=='R'),cnt_});
cnt_=1;
}
else cnt_++;
flL[i]=(str[0]=='L');
flR[i]=(str[str.size()-2]=='R');
}
sv[0].clear();
sv[0].push_back((stru){2,0});
for (int i=0; i<strv.size(); i++)
{
cnt_=0;
for (int j=1; j<=n; j++)
if (cnt[j]!=sv[j].size())
if (strv[i].id==sv[j][cnt[j]].id)
{
if (strv[i].len>=sv[j][cnt[j]].len) cnt[j]++;
else sv[c[j]][cnt[c[j]]].len-=strv[i].len;
}
}
for (int i=1; i<=n; i++)
if (cnt[i]==sv[i].size() && (fll || flL[i]) && (flr || flR[i])) printf("YES\n");
else printf("NO\n");
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 5836kb
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: 86ms
memory: 5640kb
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 NO NO NO NO YES YES YES YES YES NO NO NO YES NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO YES NO YES YES NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO ...
result:
wrong answer 22nd lines differ - expected: 'YES', found: 'NO'