# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1071280 | Ignut | 슈퍼트리 잇기 (IOI20_supertrees) | C++17 | 0 ms | 348 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// Ignut
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void build(vector<vector<int>> b);
struct DSU {
vector<int> p;
vector<vector<int>> comp;
void Init(int n) {
p.clear(), comp.clear();
for (int i = 0; i < n; i ++) p.push_back(i), comp.push_back({i});
}
int Get(int v) {
return p[v] == v ? v : p[v] = Get(p[v]);
}
void Unite(int u, int v) {
u = Get(u), v = Get(v);
if (u == v) return;
if (comp[u].size() > comp[v].size()) swap(u, v);
p[u] = v;
for (int val : comp[u]) comp[v].push_back(val);
}
};
int construct(vector<vector<int>> p) {
int n = p.size();
DSU dsu; dsu.Init(n);
for (int i = 0; i < n; i ++) {
for (int j = 0; j < n; j ++) {
if (p[i][j] == 2) {
dsu.Unite(i, j);
}
}
}
for (int i = 0; i < n; i ++) {
for (int j = 0; j < n; j ++) {
bool f1 = (p[i][j] == 2);
bool f2 = (dsu.Get(i) == dsu.Get(j));
if (f1 != f2)
return 0;
}
}
vector<vector<int>> b(n);
for (int i = 0; i < n; i ++) b[i].assign(n, 0);
for (int i = 0; i < n; i ++) {
if (dsu.Get(i) != i) continue;
if (dsu.comp[i].size() <= 2)
return 0;
// cerr << dsu.comp[i].size() << '\n';
for (int j = 0; j < dsu.comp[i].size(); j ++) {
int u = dsu.comp[i][j], v = dsu.comp[i][(j + 1) % dsu.comp[i].size()];
b[u][v] = b[v][u] = 1;
}
}
build(b);
return 1;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |