#include <bits/stdc++.h>
using namespace std;
int n,k;
int in[4001][4001];
void slow()
{
for(int i=1;i<=n;i++)
in[i][i]=1;
for(int i=1;i<=n+k-1;i++)
{
char c;
cin>>c;
int x,y;
if(c=='S')
{
cin>>x>>y;
for(int j=1;j<=n;j++)
{
in[x][j]=in[y][j]=max(in[x][j],in[y][j]);
}
}
if(c=='C')
{
cin>>x;
int cnt=0;
for(int j=1;j<=n;j++)
cnt+=in[j][x];
cout<<cnt<<endl;
}
if(c=='Q')
{
cin>>x>>y;
if(in[x][y])cout<<"yes"<<endl;
else cout<<"no"<<endl;
}
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>n>>k;
slow();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
160 ms |
3584 KB |
Output is correct |
2 |
Correct |
176 ms |
64596 KB |
Output is correct |
3 |
Correct |
185 ms |
64852 KB |
Output is correct |
4 |
Correct |
185 ms |
64744 KB |
Output is correct |
5 |
Correct |
183 ms |
64808 KB |
Output is correct |
6 |
Correct |
197 ms |
64852 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
160 ms |
3584 KB |
Output is correct |
2 |
Correct |
176 ms |
64596 KB |
Output is correct |
3 |
Correct |
185 ms |
64852 KB |
Output is correct |
4 |
Correct |
185 ms |
64744 KB |
Output is correct |
5 |
Correct |
183 ms |
64808 KB |
Output is correct |
6 |
Correct |
197 ms |
64852 KB |
Output is correct |
7 |
Correct |
149 ms |
3588 KB |
Output is correct |
8 |
Correct |
1449 ms |
64400 KB |
Output is correct |
9 |
Correct |
413 ms |
64380 KB |
Output is correct |
10 |
Correct |
1484 ms |
64416 KB |
Output is correct |
11 |
Correct |
1534 ms |
64412 KB |
Output is correct |
12 |
Correct |
344 ms |
64444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
142 ms |
3680 KB |
Output is correct |
2 |
Runtime error |
60 ms |
125884 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
142 ms |
3680 KB |
Output is correct |
2 |
Runtime error |
60 ms |
125884 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
142 ms |
3668 KB |
Output is correct |
2 |
Runtime error |
68 ms |
125780 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
142 ms |
3668 KB |
Output is correct |
2 |
Runtime error |
68 ms |
125780 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
168 ms |
3672 KB |
Output is correct |
2 |
Runtime error |
54 ms |
125988 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
168 ms |
3672 KB |
Output is correct |
2 |
Runtime error |
54 ms |
125988 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
154 ms |
3772 KB |
Output is correct |
2 |
Runtime error |
58 ms |
125924 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
154 ms |
3772 KB |
Output is correct |
2 |
Runtime error |
58 ms |
125924 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
170 ms |
3756 KB |
Output is correct |
2 |
Correct |
184 ms |
64804 KB |
Output is correct |
3 |
Correct |
172 ms |
64852 KB |
Output is correct |
4 |
Correct |
176 ms |
64596 KB |
Output is correct |
5 |
Correct |
208 ms |
64816 KB |
Output is correct |
6 |
Correct |
195 ms |
64712 KB |
Output is correct |
7 |
Correct |
161 ms |
3784 KB |
Output is correct |
8 |
Runtime error |
60 ms |
125840 KB |
Execution killed with signal 11 |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
170 ms |
3756 KB |
Output is correct |
2 |
Correct |
184 ms |
64804 KB |
Output is correct |
3 |
Correct |
172 ms |
64852 KB |
Output is correct |
4 |
Correct |
176 ms |
64596 KB |
Output is correct |
5 |
Correct |
208 ms |
64816 KB |
Output is correct |
6 |
Correct |
195 ms |
64712 KB |
Output is correct |
7 |
Correct |
161 ms |
3784 KB |
Output is correct |
8 |
Runtime error |
60 ms |
125840 KB |
Execution killed with signal 11 |
9 |
Halted |
0 ms |
0 KB |
- |