# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
621156 | Mr_Husanboy | 슈퍼트리 잇기 (IOI20_supertrees) | C++14 | 1 ms | 212 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "supertrees.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
struct DSU{
vector<int> parent, sz;
void init(int n){
parent.resize(n), sz.resize(n);
for(int i = 0; i < n; i ++) parent[i] = i, sz[i] = 1;
}
int get(int a){
return parent[a] == a ? a : parent[a] = get(parent[a]);
}
void unite(int a, int b){
a = get(a); b = get(b);
if(a==b) return;
if(sz[a] < sz[b]) swap(a,b);
sz[a] += sz[b];
parent[b] = a;
}
};
int construct(vector<vector<int>> p) {
int n = p.size();
vector<vector<int>> b(n,vector<int> (n));
DSU t; t.init(n);
for(int j = 0; j < n; j ++){
for(int i = 0; i < n; i ++){
if(p[i][j]) t.unite(i,j);
}
}
for(int i = 0; i < n; i ++){
for(int j = 0; j < n; j ++){
if(p[i][j] == 0 && t.get(i) == t.get(j)) return 0;
}
}
vector<vector<int>> par(n);
for(int i = 0; i < n; i ++){
par[t.get(i)].push_back(i);
}
for(int i = 0; i < n; i ++){
for(int j = 1; j < par[i].size(); j ++){
int u = par[i][j], v = par[i][j-1];
b[u][v] = b[v][u] = 1;
}
if(par[i].size() > 1){
int u = par[i][0], v = par[i].back();
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... |