# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
769103 | t6twotwo | 슈퍼트리 잇기 (IOI20_supertrees) | C++17 | 165 ms | 22076 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "supertrees.h"
#include <bits/stdc++.h>
using namespace std;
int construct(std::vector<std::vector<int>> a) {
int N = a.size();
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
if (a[i][j] == 3) {
return 0;
}
}
}
vector<bool> vis(N);
auto bfs = [&](int s, int t) {
vector<int> v;
queue<int> q;
q.push(s);
vis[s] = 1;
while (!q.empty()) {
int x = q.front();
q.pop();
v.push_back(x);
for (int y = 0; y < N; y++) {
if (!vis[y] && a[x][y] == t) {
vis[y] = 1;
q.push(y);
}
}
}
return v;
};
vector ans(N, vector<int>(N));
for (int i = 0; i < N; i++) {
if (vis[i]) {
continue;
}
auto v = bfs(i, 1);
for (int x : v) {
for (int j = 0; j < N; j++) {
if (a[x][j] != a[v[0]][j]) {
return 0;
}
}
}
for (int j = 1; j < v.size(); j++) {
ans[i][v[j]] = ans[v[j]][i] = 1;
}
vis[i] = 0;
}
for (int i = 0; i < N; i++) {
if (vis[i]) {
continue;
}
auto v = bfs(i, 2);
if (v.size() == 1) {
continue;
}
if (v.size() == 2) {
return 0;
}
for (int j = 0; j < v.size(); j++) {
for (int k = j + 1; k < v.size(); k++) {
if (!a[v[j]][v[k]]) {
return 0;
}
}
}
for (int j = 0; j < v.size(); j++) {
int x = v[j];
int y = v[j + 1 == v.size() ? 0 : j + 1];
ans[x][y] = ans[y][x] = 1;
}
}
build(ans);
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... |