#include <bits/stdc++.h>
//Announcing plan to get the test data is probably not a good idea
using namespace std;
bitset<1005>arr[120000];
int ty[300010], b[300100], c[300100];
int ans[300100];
int main()
{
int N, K;
cin >> N >> K;
int i;
for (i = 0; i < N + K - 1; i++)
{
char a;
cin >> a;
if (a == 'S')
{
ty[i] = 0;
cin >> b[i] >> c[i];
}
else if (a == 'Q')
{
ty[i] = 1;
cin >> b[i] >> c[i];
}
else
{
ty[i] = 2;
cin >> b[i];
}
}
for (i = 1; i <= N; i += 1000)
{
int j;
for (j = 1; j <= N; j++)
{
if (j >= i && j < i + 1000)
arr[j].set(j-i);
}
for (j = 0; j < N + K - 1; j++)
{
if (ty[j] == 0)
{
arr[b[j]] |= arr[c[j]];
arr[c[j]] |= arr[b[j]];
}
else if (ty[j] == 1)
{
if (c[j] < i || c[j] >= i + 1000)
continue;
ans[j] = arr[b[j]][c[j] - i];
}
else
{
if (b[j] < i || b[j] >= i + 1000)
continue;
int k;
for (k = 1; k <= N; k++)
{
ans[j] += arr[k][b[j] - i];
}
}
}
}
for (i = 0; i < N + K - 1; i++)
{
if (ty[i] == 1)
{
cout << (ans[i] ? "yes" : "no") << '\n';
}
else if (ty[i] == 2)
cout << ans[i] << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
56 ms |
3380 KB |
Output is correct |
2 |
Incorrect |
75 ms |
4388 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
56 ms |
3380 KB |
Output is correct |
2 |
Incorrect |
75 ms |
4388 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
54 ms |
3404 KB |
Output is correct |
2 |
Incorrect |
1710 ms |
22320 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
54 ms |
3404 KB |
Output is correct |
2 |
Incorrect |
1710 ms |
22320 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
61 ms |
3420 KB |
Output is correct |
2 |
Correct |
1906 ms |
22784 KB |
Output is correct |
3 |
Incorrect |
1895 ms |
22860 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
61 ms |
3420 KB |
Output is correct |
2 |
Correct |
1906 ms |
22784 KB |
Output is correct |
3 |
Incorrect |
1895 ms |
22860 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
55 ms |
3332 KB |
Output is correct |
2 |
Incorrect |
561 ms |
22736 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
55 ms |
3332 KB |
Output is correct |
2 |
Incorrect |
561 ms |
22736 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
56 ms |
3400 KB |
Output is correct |
2 |
Correct |
2024 ms |
22832 KB |
Output is correct |
3 |
Incorrect |
1979 ms |
22860 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
56 ms |
3400 KB |
Output is correct |
2 |
Correct |
2024 ms |
22832 KB |
Output is correct |
3 |
Incorrect |
1979 ms |
22860 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
59 ms |
3452 KB |
Output is correct |
2 |
Incorrect |
79 ms |
4480 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
59 ms |
3452 KB |
Output is correct |
2 |
Incorrect |
79 ms |
4480 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |