QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#671967#9425. Generated StringzhuifengquWA 1ms3872kbC++141.2kb2024-10-24 15:09:532024-10-24 15:09:53

Judging History

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

  • [2024-10-24 15:09:53]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3872kb
  • [2024-10-24 15:09:53]
  • 提交

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'