| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 401033 | dxz05 | 슈퍼트리 잇기 (IOI20_supertrees) | C++14 | 274 ms | 24088 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "supertrees.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1111;
int par[MAXN][3];
int find_set(int x, int flag){
if (x == par[x][flag]) return x;
return par[x][flag] = find_set(par[x][flag], flag);
}
bool union_sets(int x, int y, int flag){
x = find_set(x, flag);
y = find_set(y, flag);
if (x == y) return false;
if (rand() % 2) swap(x, y);
par[x][flag] = y;
return true;
}
vector<int> children[MAXN];
int construct(vector<vector<int>> p) {
int n = p.size();
vector<vector<int>> answer(n, vector<int>(n, 0));
for (int i = 0; i < n; i++) par[i][1] = par[i][2] = i;
for (int i = 0; i < n; i++){
for (int j = 0; j < n; j++){
if (p[i][j] == 1) union_sets(i, j, 1);
}
}
for (int i = 0; i < n; i++){
for (int j = 0; j < n; j++){
if (p[i][j] == 2){
int x = find_set(i, 1), y = find_set(j, 1);
union_sets(x, y, 2);
}
}
}
for (int i = 0; i < n; i++){
children[find_set(i, 2)].push_back(i);
}
for (int i = 0; i < n; i++){
if (children[i].size() < 2) continue;
children[i].push_back(children[i].front());
for (int j = 0; j < children[i].size() - 1; j++){
int x = children[i][j], y = children[i][j + 1];
answer[x][y] = answer[y][x] = 1;
}
}
for (int i = 0; i < n; i++){
int x = find_set(i, 1);
if (x != i) answer[i][x] = answer[x][i] = 1;
}
build(answer);
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... | ||||
