QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#671967 | #9425. Generated String | zhuifengqu | WA | 1ms | 3872kb | C++14 | 1.2kb | 2024-10-24 15:09:53 | 2024-10-24 15:09:53 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int main()
{
int h = 0;
long long n, q;
cin >> n >> q;
string S;
cin >> S;
multiset<string> strSet;
vector<string>A(q + 1, "");
for (int i = 1; i <= q; i++)
{
char c;
cin >> c;
if (c == '+')
{
h++;
string d="";
int k;
cin >> k;
for (int j = 1; j <= k; j++)
{
int a, b;
cin >> a >> b;
d += S.substr(a - 1, b - a + 1);
}
strSet.insert(d);
A[h] = d;
}
else if (c == '-')
{
long long t;
cin >> t;
string targetStr = A[t];
strSet.erase(strSet.find(targetStr));
h++;
}
else if (c == '?')
{
h++;
long long k;
cin >> k;
string f="";
for (int j = 1; j <= k; j++)
{
int a, b;
cin >> a >> b;
f += S.substr(a - 1, b - a + 1);
}
long long m;
cin >> m;
string e="";
for (int j = 1; j <= m; j++)
{
int a, b;
cin >> a >> b;
e += S.substr(a - 1, b - a + 1);
}
long long p = 0;
for (auto curStr : strSet)
{
if (curStr.find(f) == 0 && curStr.rfind(e) == curStr.length() - e.length())
{
p++;
}
}
cout << p << endl;
}
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3604kb
input:
8 7 abcaabbc + 3 1 3 2 4 3 8 + 2 1 4 1 8 + 1 2 4 ? 1 5 6 1 7 8 - 3 + 1 2 5 ? 1 2 3 1 5 5
output:
2 1
result:
ok 2 lines
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3872kb
input:
5 2000 bbaab + 1 3 5 + 2 5 5 3 5 - 2 ? 1 1 3 3 3 3 4 5 2 5 - 1 ? 3 1 1 2 4 1 5 1 3 4 ? 1 1 2 2 2 4 4 4 ? 1 1 5 1 5 5 + 3 1 2 1 5 1 4 ? 2 1 5 1 3 2 1 2 5 5 ? 1 3 4 1 4 5 - 9 ? 1 1 4 1 2 3 + 2 1 5 1 2 + 1 1 4 - 15 - 14 ? 2 2 5 2 5 1 3 4 + 1 2 3 - 19 + 3 1 4 1 5 4 5 - 21 + 1 2 5 ? 3 1 5 5 5 1 5 1 3 5 ?...
output:
0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 2 0 0 1 0 0 0 0 0 0 1 2 0 4 1 0 0 1 1 1 0 0 0 0 0 0 0 0 2 0 2 0 0 0 1 0 4 0 0 0 0 0 3 1 0 1 0 2 0 1 0 3 1 3 0 0 2 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 1 1 2 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 1 0 0 0 0 1 0 0 1 0 0 1 1 3 2 3 0 1 0 0 0 2 0 0 2 0 0 0 2 3 ...
result:
wrong answer 24th lines differ - expected: '0', found: '1'