# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1043745 | DeathIsAwe | 슈퍼트리 잇기 (IOI20_supertrees) | C++14 | 109 ms | 24200 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "supertrees.h"
#include <bits/stdc++.h>
using namespace std;
int construct(vector<vector<int>> p) {
int n = p.size(), prev;
vector<vector<int>> ans(n), forest;
vector<int> tree;
bool visited[n];
for (int i=0;i<n;i++) {
visited[i] = false;
for (int j=0;j<n;j++) {
ans[i].push_back(0);
}
}
for (int i=0;i<n;i++) {
if (visited[i]) {
continue;
}
visited[i] = true;
tree.clear(); tree.push_back(i);
for (int j=0;j<n;j++) {
if (j == i) {
continue;
}
if (p[i][j] == 1) {
if (visited[j]) {
return 0;
}
visited[j] = true;
tree.push_back(j);
} else if (p[i][j] == 3) {
return 0;
}
}
prev = i;
for (int j: tree) {
ans[prev][j] = 1;
ans[j][prev] = 1;
prev = j;
}
ans[i][i] = 0;
for (int j: tree) {
for (int k: tree) {
if (p[j][k] != 1) {
return 0;
}
}
}
forest.push_back(tree);
}
for (int i=0;i<n;i++) {
visited[i] = false;
}
vector<int> group;
vector<int> grouptags(forest.size(), -1);
for (int i=0;i<forest.size();i++) {
if (visited[forest[i][0]]) {
continue;
}
visited[forest[i][0]] = true;
group = {i};
grouptags[i] = i;
for (int j=i+1;j<forest.size();j++) {
if (p[forest[i][0]][forest[j][0]] == 2) {
visited[forest[j][0]] = true;
group.push_back(j);
grouptags[j] = i;
}
}
//for (int j: group) {
// cout << j << ' ';
//}
//cout << '\n';
if (group.size() == 2) {
return 0;
}
for (int j: group) {
for (int k=0;k<forest.size();k++) {
if (j == k) {
continue;
}
if (grouptags[k] != i) {
for (int l: forest[k]) {
for (int m: forest[j]) {
if (p[m][l] != 0) {
return 0;
}
}
}
} else {
for (int l: forest[k]) {
for (int m: forest[j]) {
if (p[m][l] != 2) {
return 0;
}
}
}
}
}
}
prev = forest[i][0];
for (int j: group) {
ans[prev][forest[j][0]] = 1;
ans[forest[j][0]][prev] = 1;
prev = forest[j][0];
}
ans[forest[i][0]][forest[i][0]] = 0;
if (prev ==forest[i][0]) {
continue;
}
ans[prev][forest[i][0]] = 1;
ans[forest[i][0]][prev] = 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... |