| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 313776 | nikatamliani | 슈퍼트리 잇기 (IOI20_supertrees) | C++14 | 275 ms | 22264 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#include "supertrees.h"
int find_set(int x, vector < int > &parent) {
return parent[x] == x ? x : parent[x] = find_set(parent[x], parent);
}
void union_sets(int x, int y, vector < int > &parent) {
x = find_set(x, parent);
y = find_set(y, parent);
parent[x] = y;
}
int construct(vector < vector < int > > p) {
int n = p.size();
vector < int > parent(n);
for(int i = 0; i < n; ++i) parent[i] = i;
for(int i = 0; i < n; ++i) {
for(int j = 0; j < n; ++j) {
if(p[i][j] != p[j][i] || p[i][j] == 3) return 0;
if(p[i][j] > 0) {
union_sets(i, j, parent);
}
}
}
for(int i = 0; i < n; ++i) {
for(int j = 0; j < n; ++j) {
if(find_set(i, parent) == find_set(j, parent) && !p[i][j]) {
return 0;
}
}
}
vector < vector < int > > g(n, vector < int >(0, 0));
for(int i = 0; i < n; ++i) {
g[find_set(i, parent)].push_back(i);
}
for(int i = 0; i < n; ++i) parent[i] = i;
vector < vector < int > > edges(n, vector < int >(n, 0));
for(int i = 0; i < n; ++i) {
if(g[i].empty()) continue;
for(int x : g[i]) {
for(int y : g[i]) {
if(p[x][y] == 1) {
union_sets(x, y, parent);
}
}
}
for(int x : g[i]) {
for(int y : g[i]) {
if(find_set(x, parent) == find_set(y, parent) && p[x][y] == 2) {
return 0;
}
}
}
vector < int > last(n, -1), parents;
for(int x : g[i]) {
int pp = find_set(x, parent);
if(~last[pp]) {
edges[last[pp]][x] = edges[x][last[pp]] = 1;
}
last[pp] = x;
if(x == pp) {
parents.push_back(x);
}
}
for(int j = 1; j < parents.size(); ++j) {
int from = parents[j - 1], to = parents[j];
edges[from][to] = edges[to][from] = 1;
}
int from = parents.back(), to = parents[0];
if(from != to) {
edges[from][to] = edges[to][from] = 1;
}
}
build(edges);
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... | ||||
