| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1029353 | elpro123 | 슈퍼트리 잇기 (IOI20_supertrees) | C++14 | 130 ms | 31920 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "supertrees.h"
#include<bits/stdc++.h>
using namespace std;
int p[1000][1000],ans[1000][1000];
void add(int v,int u){
ans[v][u] = ans[u][v] = 1;
}
int construct(vector<vector<int>> P){
int n = P.size();
for(int i=0; i<n; i++){
for(int j=0; j<n; j++){
p[i][j] = P[i][j];
if(p[i][j] == 3){
return 0;
}
}
}
//find all nodes connected to 1
//then nodes with p(1,v) = 1
//this has to form a tree
//repeat forming many trees then link the trees in a cycle
vector<int> ded(n,0);
for(int i=0; i<n; i++){
if(ded[i]){
continue;
}
vector<int> comp;
vector<bool> incomp(n,0);
for(int j=0; j<n; j++){
if(ded[j]){
continue;
}
if(p[i][j]){
incomp[j] = 1;
comp.push_back(j);
ded[j] = 1;
}
}
vector<vector<int>> trees;
while(!comp.empty()){
int v = comp[0];
vector<int> tree,tmp;
for(int u: comp){
if(p[u][v] == 1){
tree.push_back(u);
}else{
tmp.push_back(u);
}
}
trees.push_back(tree);
comp = tmp;
}
int ss = trees.size();
if(ss > 1){
add(trees[0][0], trees[ss-1][0]);
}
for(int i=0; i<ss; i++){
if(i+1<trees.size()){
add(trees[i][0],trees[i+1][0]);
}
for(int j=0; j+1<trees[i].size(); j++){
add(trees[i][j],trees[i][j+1]);
}
}
}
vector<vector<int>> fin(n);
for(int i=0; i<n; i++){
fin[i].assign(n,0);
for(int j=0; j<n; j++){
fin[i][j] = ans[i][j];
}
}
build(fin);
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... | ||||
