# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
869781 | 2023-11-05T16:11:00 Z | Ariadna | ICC (CEOI16_icc) | C++14 | 0 ms | 0 KB |
#include <bits/stdc++.h> #include "icc.h" using namespace std; int query(int size_a, int size_b, vector < int > a, vector < int > b); void setRoad(int a, int b); vector < int > p; int root(int a) { if (p[a] == a) return a; return p[a] = root(p[a]); } void join(int a, int b) { p[root(a)] = root(b); } void run(int N) { p = vector < int >(N); for (int i = 0; i < N; ++i) { p[i] = i; } for (int t = 1; t < N; ++t) { bool founded = false; for (int i = 0; i < N && !founded; ++i) { for (int j = i + 1; j < N && !founded; ++j) { if (root(i) == root(j)) continue; vector < int > a = {i + 1}, b = {j + 1}; if (query(1, 1, a, b)) { setRoad(i + 1, j + 1); join(i, j); founded = true; } } } } }