Submission #734894

#TimeUsernameProblemLanguageResultExecution timeMemory
734894Elvin_FritlConnecting Supertrees (IOI20_supertrees)C++17
21 / 100
198 ms24096 KiB
//#include "supertrees.h" #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 0; } for(int k=0;k<(int)c2.size();k++){ if(p[j][c2[k]] != 0) return 0; } } 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 0; } } 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 0; } } 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 2; } } 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...