#include "game.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> la, sd;
int n, k;
int par(vector<int>& p, int i){
if (i == p[i]){
return i;
}
return(p, p[i]);
}
void init(int N, int K) {
n = N;
k = K;
la.resize(n);
sd.resize(n);
iota(la.begin(), la.end(), 0);
iota(sd.begin(), sd.end(), 0);
}
int add_teleporter(int u, int v) {
sd[u] = min(par(sd, v), par(sd, u));
la[v] = min(par(la, v), par(la, u));
if (sd[u] < la[u] && sd[u] < k && la[u] < k){
return 1;
}
if (sd[v] < la[v] && sd[v] < k && la[v] < k){
return 1;
}
return 0;
}
int nothing() {
int n, k, m;
cin >> n >> k >> m;
init(n, k);
for (int i = 0; i < m; ++i){
int a, b;
cin >> a >> b;
cout << add_teleporter(a, b) << endl;
}
return 0;
}
Compilation message
game.cpp: In function 'int par(std::vector<int>&, int)':
game.cpp:10:9: warning: left operand of comma operator has no effect [-Wunused-value]
10 | return(p, p[i]);
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
208 KB |
Wrong Answer[1] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
208 KB |
Wrong Answer[1] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
208 KB |
Wrong Answer[1] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
208 KB |
Wrong Answer[1] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
208 KB |
Wrong Answer[1] |
2 |
Halted |
0 ms |
0 KB |
- |