# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
869781 | Ariadna | ICC (CEOI16_icc) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
}
}
}
}