Submission #302040

#TimeUsernameProblemLanguageResultExecution timeMemory
302040arthurconmyConnecting Supertrees (IOI20_supertrees)C++14
0 / 100
1 ms384 KiB
#include <bits/stdc++.h> using namespace std; #ifndef ARTHUR_LOCAL #include "supertrees.h" #endif #ifdef ARTHUR_LOCAL void build(vector<vector<int>> V) { for(auto row:V) { for(auto thing:row) cout << thing << " "; cout << endl; } } #endif vector<int> comp; vector<int> adj[1001]; bool vis[1001]; void dfs(int v) { vis[v]=1; comp.push_back(v); for(auto u:adj[v]) { if(vis[u]) continue; dfs(u); } } int construct(vector<vector<int>> P) { int n = (int)P.size(); vector<vector<int>> answer; for (int i = 0; i < n; i++) { vector<int> row(n); answer.push_back(row); } for(int i=0; i<n; i++) { for(int j=i+1; j<n; j++) { if(P[i][j]==1) { adj[i].push_back(j); adj[j].push_back(i); } } } for(int i=0; i<n; i++) { comp.clear(); dfs(i); int m = (int)comp.size(); if(m==1) continue; // for(au) for(int i=0; i<m; i++) { for(int j=i+1; j<m; j++) { if(P[comp[i]][comp[j]]!=2) return 0; } } for(int i=0; i<m; i++) { answer[comp[i]][comp[(i+1)%m]]=1; answer[comp[(i+1)%m]][comp[i]]=1; } } build(answer); return 1; } #ifdef ARTHUR_LOCAL int main() { construct({{1,1,0},{1,1,0},{0,0,1}}); } #endif
#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...