# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
941237 | Numberz | 슈퍼트리 잇기 (IOI20_supertrees) | C++14 | 179 ms | 22356 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "supertrees.h"
#include <bits/stdc++.h>
using namespace std;
int construct(vector<std::vector<int>> p) {
//subtask 1
int n = p.size();
vector<vector<int>> res(n, vector<int>(n, 0));
//checker
vector<int> tracker(n, 0);
vector<vector<int>> components;
//checks if it is possible to build the bridges
for (int i = 0; i < n; i++) {
//checks if it should already be in a component
bool search = true;
for (int j = 0; j < components.size(); j++) {
if (p[components[j][0]][i] == 2) {
components[j].push_back(i);
//cout << "prob first " << i << ' ' << j <<endl;
//cout << "j: " << j << endl;
tracker[i] = j;
search = false;
break;
}
}
if (search) {
components.push_back({i});
//cout << "prob second " << i << ' ' << components.size()-1 <<endl;
//cout << "comps: " << components.size() << endl;
tracker[i] = components.size()-1;
}
}
//check if wrong
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (i != j) {
if ((tracker[i] == tracker[j] && p[i][j] == 0) || (tracker[i] != tracker[j] && p[i][j] != 0)) {
return 0;
}
}
}
}
//within each component, build a graph
// size shoud be > 1
for (auto comp : components) {
if (comp.size() > 1) {
if (comp.size() == 2) {
return 0;
}
int k = comp.size();
for (int i = 0; i < k-1; i++) {
res[comp[i]][comp[i+1]] = 1;
res[comp[i+1]][comp[i]] = 1;
}
res[comp[k-1]][comp[0]] = 1;
res[comp[0]][comp[k-1]] = 1;
}
}
build(res);
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... |