# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
300703 | 2020-09-17T12:19:34 Z | nandonathaniel | 슈퍼트리 잇기 (IOI20_supertrees) | C++14 | 278 ms | 24164 KB |
#include "supertrees.h" #include "bits/stdc++.h" using namespace std; typedef pair<int,int> pii; const int MAXN=1005; int par[MAXN]; bool idx[MAXN]; vector<int> kel[MAXN],kelkecil[MAXN]; int find(int x){ if(par[x]==x)return par[x]; return par[x]=find(par[x]); } void join(int a,int b){ int ortua=find(a),ortub=find(b); par[ortua]=ortub; } int construct(vector<vector<int>> p){ vector<pii> nol; vector<vector<int>> ans; int n = p.size(); for(int i=0;i<n;i++)par[i]=i; ans.resize(n); for(int i=0;i<n;i++){ ans[i].resize(n); for(int j=0;j<n;j++){ ans[i][j]=0; if(i==j)continue; if(p[i][j])join(i,j); else if(i<j)nol.push_back({i,j}); } } for(auto isi : nol){ if(find(isi.first)==find(isi.second))return 0; } for(int i=0;i<n;i++)kel[find(i)].push_back(i); for(int i=0;i<n;i++){ if(kel[i].size()<=1)continue; for(int j=0;j<n;j++){ kelkecil[j].clear(); par[j]=j; idx[j]=false; } for(auto isi : kel[i]){ for(auto isi2 : kel[i]){ if(p[isi][isi2]==1)join(isi,isi2); } } for(auto isi : kel[i])kelkecil[find(isi)].push_back(isi); vector<vector<int>> satu; vector<int> dua; for(int j=0;j<n;j++){ if(kelkecil[j].size()<=1)continue; satu.push_back(kelkecil[j]); } for(auto isi : satu){ for(auto isi2 : isi)idx[isi2]=true; } for(auto isi : kel[i]){ if(!idx[isi])dua.push_back(isi); } vector<int> cycle; for(auto isi : dua)cycle.push_back(isi); for(auto isi : satu)cycle.push_back(isi.back()); if(cycle.size()<3)return 0; for(auto isi : satu){ for(int j=0;j<isi.size()-1;j++){ ans[isi[j]][isi[j+1]]=1; ans[isi[j+1]][isi[j]]=1; } } for(int j=0;j<cycle.size();j++){ ans[cycle[j]][cycle[(j+1)%cycle.size()]]=1; ans[cycle[(j+1)%cycle.size()]][cycle[j]]=1; } } build(ans); return 1; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Incorrect | 1 ms | 384 KB | Answer gives possible 0 while actual possible 1 |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Incorrect | 1 ms | 384 KB | Answer gives possible 0 while actual possible 1 |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 512 KB | Output is correct |
7 | Correct | 1 ms | 384 KB | Output is correct |
8 | Correct | 11 ms | 1368 KB | Output is correct |
9 | Correct | 265 ms | 24036 KB | Output is correct |
10 | Correct | 1 ms | 384 KB | Output is correct |
11 | Correct | 1 ms | 384 KB | Output is correct |
12 | Correct | 11 ms | 1280 KB | Output is correct |
13 | Correct | 265 ms | 22136 KB | Output is correct |
14 | Correct | 1 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
16 | Correct | 6 ms | 1024 KB | Output is correct |
17 | Correct | 135 ms | 14184 KB | Output is correct |
18 | Correct | 1 ms | 384 KB | Output is correct |
19 | Correct | 1 ms | 384 KB | Output is correct |
20 | Correct | 1 ms | 384 KB | Output is correct |
21 | Correct | 68 ms | 6260 KB | Output is correct |
22 | Correct | 262 ms | 23648 KB | Output is correct |
23 | Correct | 265 ms | 24164 KB | Output is correct |
24 | Correct | 278 ms | 22380 KB | Output is correct |
25 | Correct | 122 ms | 16104 KB | Output is correct |
26 | Correct | 125 ms | 15716 KB | Output is correct |
27 | Correct | 269 ms | 24036 KB | Output is correct |
28 | Correct | 271 ms | 22316 KB | Output is correct |
29 | Correct | 121 ms | 16100 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Incorrect | 1 ms | 384 KB | Answer gives possible 0 while actual possible 1 |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Incorrect | 1 ms | 384 KB | Answer gives possible 0 while actual possible 1 |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Incorrect | 1 ms | 384 KB | Answer gives possible 0 while actual possible 1 |
3 | Halted | 0 ms | 0 KB | - |