#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define pb push_back
#define pii pair<int, int>
#define chmin(x, v) x = min(x, v)
#define chmax(x, v) x = max(x, v)
#define print(x) cout << #x << " est " << x << endl;
#define x first
#define y second
#define int long long
using namespace std;
const int N = 4005;
bool la[N][N];
int np[N];
signed main(){
int nServs, nReqs; cin >> nServs >> nReqs;
for (int i = 1; i <= nServs; ++i)
la[i][i] = true, np[i] = 1;
nReqs += nServs - 1;
while (nReqs--){
char typeReq; cin >> typeReq;
if (typeReq == 'S'){
int a, b; cin >> a >> b;
for (int i = 1; i <= nServs; ++i){
np[i] -= (la[a][i] + la[b][i]);
la[a][i] = la[b][i] = (la[a][i]|la[b][i]);
np[i] += (la[a][i] + la[b][i]);
}
}
else if (typeReq == 'Q'){
int a, d; cin >> a >> d;
if (la[a][d]) cout << "yes" << endl;
else cout << "no" << endl;
}
else {
int d; cin >> d;
cout << np[d] << endl;
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
193 ms |
1028 KB |
Output is correct |
2 |
Correct |
245 ms |
16548 KB |
Output is correct |
3 |
Correct |
241 ms |
16612 KB |
Output is correct |
4 |
Correct |
252 ms |
16596 KB |
Output is correct |
5 |
Correct |
245 ms |
16748 KB |
Output is correct |
6 |
Correct |
247 ms |
16580 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
193 ms |
1028 KB |
Output is correct |
2 |
Correct |
245 ms |
16548 KB |
Output is correct |
3 |
Correct |
241 ms |
16612 KB |
Output is correct |
4 |
Correct |
252 ms |
16596 KB |
Output is correct |
5 |
Correct |
245 ms |
16748 KB |
Output is correct |
6 |
Correct |
247 ms |
16580 KB |
Output is correct |
7 |
Correct |
190 ms |
952 KB |
Output is correct |
8 |
Correct |
238 ms |
16552 KB |
Output is correct |
9 |
Correct |
231 ms |
17316 KB |
Output is correct |
10 |
Correct |
232 ms |
17400 KB |
Output is correct |
11 |
Correct |
228 ms |
17312 KB |
Output is correct |
12 |
Correct |
240 ms |
17484 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
191 ms |
976 KB |
Output is correct |
2 |
Runtime error |
19 ms |
32296 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
191 ms |
976 KB |
Output is correct |
2 |
Runtime error |
19 ms |
32296 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
191 ms |
808 KB |
Output is correct |
2 |
Runtime error |
19 ms |
32212 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
191 ms |
808 KB |
Output is correct |
2 |
Runtime error |
19 ms |
32212 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
194 ms |
1016 KB |
Output is correct |
2 |
Runtime error |
22 ms |
32240 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
194 ms |
1016 KB |
Output is correct |
2 |
Runtime error |
22 ms |
32240 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
195 ms |
816 KB |
Output is correct |
2 |
Runtime error |
22 ms |
32260 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
195 ms |
816 KB |
Output is correct |
2 |
Runtime error |
22 ms |
32260 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
193 ms |
904 KB |
Output is correct |
2 |
Correct |
256 ms |
16352 KB |
Output is correct |
3 |
Correct |
246 ms |
16352 KB |
Output is correct |
4 |
Correct |
255 ms |
16332 KB |
Output is correct |
5 |
Correct |
244 ms |
16344 KB |
Output is correct |
6 |
Correct |
252 ms |
16460 KB |
Output is correct |
7 |
Correct |
186 ms |
812 KB |
Output is correct |
8 |
Runtime error |
20 ms |
32276 KB |
Execution killed with signal 11 |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
193 ms |
904 KB |
Output is correct |
2 |
Correct |
256 ms |
16352 KB |
Output is correct |
3 |
Correct |
246 ms |
16352 KB |
Output is correct |
4 |
Correct |
255 ms |
16332 KB |
Output is correct |
5 |
Correct |
244 ms |
16344 KB |
Output is correct |
6 |
Correct |
252 ms |
16460 KB |
Output is correct |
7 |
Correct |
186 ms |
812 KB |
Output is correct |
8 |
Runtime error |
20 ms |
32276 KB |
Execution killed with signal 11 |
9 |
Halted |
0 ms |
0 KB |
- |