# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
812484 | KemalK | Connecting Supertrees (IOI20_supertrees) | C++17 | 1178 ms | 2031208 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "supertrees.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 5;
int pr[N];
int sz[N];
int get(int x){
if (pr[x] == x){
return x;
}
return pr[x] == get(pr[x]);
}
void unit(int a, int b){
a = get(a);
b = get(b);
if (a != b){
if (sz[a] < sz[b]){
swap(a, b);
}
pr[b] = a;
sz[a] += sz[b];
}
}
int construct(std::vector<std::vector<int>> p) {
int n = p.size();
bool sub_task_1 = true;
bool sub_task_2 = true;
for (int i = 0; i < n; i++){
pr[i] = i;
}
for (int i = 0; i < n; i++){
for (int j = 0; j < n; j++){
if (i != j and p[i][j]){
unit(i, j);
}
}
}
for (int i = 0; i < n; i++){
for (int j = 0; j < n; j++){
if (p[i][j] != 1){
sub_task_1 = false;
}
if (p[i][j] != 2 and p[i][j] != 3){
sub_task_2 = false;
}
}
}
std::vector<std::vector<int>> answer;
for (int i = 0; i < n; i++) {
std::vector<int> row;
row.resize(n);
answer.push_back(row);
}
if (n == 1){
//nothing to change
}
else if (sub_task_1){ // p[i][j] = 1
for (int i = 0; i < n - 1; i++){
answer[i][i + 1] = 1;
answer[i + 1][i] = 1;
}
}
else if(sub_task_2) { // p[i][j] = 1 or p[i][j] = 0
map <int, vector<int>> mp;
for (int i = 0; i < n; i++){
int x = get(i);
mp[x].push_back(i);
}
for (auto x: mp){
for (int i = 0; i < x.second.size() - 1; i++){
answer[x.second[i]][x.second[i + 1]] = 1;
answer[x.second[i + 1]][x.second[i]] = 1;
}
}
}
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... |