| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 303274 | Kevin_Zhang_TW | 슈퍼트리 잇기 (IOI20_supertrees) | C++17 | 270 ms | 26200 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "supertrees.h"
#include <vector>
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
#ifdef KEV
#define DE(i, e) cerr << #i << ' ' << i << e
void debug(auto L, auto R) { while (L < R) cerr << *L << " \n"[L+1==R], ++L; }
#else
#define DE(...) 0
void debug(...) {}
#endif
const int maxn = 300010;
int g[maxn], sz[maxn], n;
int find(int i) { return g[i] == i ? g[i] : g[i] = find(g[i]); }
std::vector<std::vector<int>> p;
bool merge(int a, int b) {
a = find(a), b = find(b);
if (a == b) return false;
if ( sz[a] < sz[b]) swap(a, b);
sz[a] += sz[b];
return g[b] = a, true;
}
void dsuinit() {
for (int i = 0;i < n;++i)
g[i] = i, sz[i] = 1;
}
bool build_ok(vector<vector<int>> &edge) {
dsuinit();
for (int i = 0;i < n;++i)
for (int j = i+1;j < n;++j)
if (p[i][j] && merge(i, j))
edge[i][j] = edge[j][i] = true;
for (int i = 0;i < n;++i)
for (int j = i+1;j < n;++j)
if (!p[i][j] && find(i) == find(j))
return false;
return true;
}
int construct(std::vector<std::vector<int>> p) {
n = p.size();
::p = p;
std::vector<std::vector<int>> answer;
for (int i = 0; i < n; i++) {
std::vector<int> row(n);
answer.push_back(row);
}
if (!build_ok(answer))
return 0;
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... | ||||
