#include "game.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> la, sd;
int n, k;
int par(vector<int>& p, int i){
//cout << i << endl;
if (i == p[i]){
return i;
}
return par(p, p[i]);
}
int solvesmaller(int a, int b, int k){
if (a >= k){
return b;
}
if (b >= k){
return a;
}
return min(a, b);
}
int solvelarger(int a, int b, int k){
if (a >= k){
return b;
}
if (b >= k){
return a;
}
return max(a, b);
}
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[par(sd, u)] = solvesmaller(par(sd, v), par(sd, u), k);
la[par(la, v)] = solvelarger(par(la, v), par(la, u), k);
if (par(sd, u) < par(la, u) && par(sd, u) < k && par(la, u) < k){
return 1;
}
if (par(sd, v) < par(la, v) && par(sd, v) < k && par(la, v) < k){
return 1;
}
return 0;
}
int nothing() {
int n, k;
cin >> n >> k;
init(n, k);
int m = 0;
while (m != 1){
int a, b;
cin >> a >> b;
m = add_teleporter(a, b);
cout << add_teleporter(a, b) << endl;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
Wrong Answer[1] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
Wrong Answer[1] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
Wrong Answer[1] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
Wrong Answer[1] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
Wrong Answer[1] |
2 |
Halted |
0 ms |
0 KB |
- |