제출 #672566

#제출 시각아이디문제언어결과실행 시간메모리
672566tbzard슈퍼트리 잇기 (IOI20_supertrees)C++14
11 / 100
179 ms22144 KiB
#include <bits/stdc++.h> using namespace std; void build(vector<vector<int> > b); bool vis[1002]; int construct(vector<vector<int> > p) { int n = (int)p.size(); vector<vector<int> > ans(n); for(int i=0;i<n;i++) ans[i].resize(n); for(int i=0;i<n;i++){ if(vis[i]) continue; vis[i] = 1; vector<int> c1, c2; for(int j=i+1;j<n;j++){ if(p[i][j] == 1){ c1.push_back(j); vis[j] = 1; } } for(int j=i+1;j<n;j++){ if(p[i][j] == 2){ c2.push_back(j); vis[j] = 1; } } for(int j=i+1;j<n;j++){ if(vis[j]) continue; for(int k=0;k<(int)c1.size();k++){ if(p[j][c1[k]] != 0) return 2; } for(int k=0;k<(int)c2.size();k++){ if(p[j][c2[k]] != 0) return 3; } } for(int j=0;j<(int)c1.size();j++){ for(int k=0;k<(int)c1.size();k++){ if(j == k) continue; if(p[c1[j]][c1[k]] != 1) return 4; } } for(int j=0;j<(int)c1.size();j++){ for(int k=0;k<(int)c2.size();k++){ if(p[c1[j]][c2[k]] != 2) return 5; } } for(int j=0;j<(int)c2.size();j++){ for(int k=0;k<(int)c2.size();k++){ if(j == k) continue; if(p[c2[j]][c2[k]] != 2) return 6; } } for(int j=0;j<(int)c1.size();j++){ ans[i][c1[j]] = 1; ans[c1[j]][i] = 1; } if((int)c2.size() == 1) return 0; else if((int)c2.size() > 1){ ans[i][c2[0]] = 1; ans[c2[0]][i] = 1; ans[i][c2[c2.size()-1]] = 1; ans[c2[c2.size()-1]][i] = 1; for(int j=0;j<(int)c2.size()-1;j++){ ans[c2[j]][c2[j+1]] = 1; ans[c2[j+1]][c2[j]] = 1; } } } build(ans); return 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...