Submission #601061

#TimeUsernameProblemLanguageResultExecution timeMemory
601061FatihSolakConnecting Supertrees (IOI20_supertrees)C++17
46 / 100
204 ms24012 KiB
#include "supertrees.h" #include <bits/stdc++.h> #define N 1005 using namespace std; int construct(vector<vector<int>> p){ int n = p.size(); vector<vector<int>> answer; for (int i = 0; i < n; i++) { vector<int> row; row.resize(n); answer.push_back(row); } vector<bool> vis(n); for(int i = 0;i<n;i++){ if(!vis[i]){ vector<int> vis2(n); vector<int> now; for(int j = 0;j<n;j++){ if(p[i][j]){ vis[j] = 1; now.push_back(j); } } vector<int> circle; for(auto u:now){ if(vis2[u])continue; circle.push_back(u); for(int j = 0;j<n;j++){ if(p[u][j] == 1){ vis2[j] = 1; if(u != j){ answer[u][j] = answer[j][u] = 1; } } } } int sz = circle.size(); if(sz != 1){ for(int j = 0;j<sz;j++){ answer[circle[j]][circle[(j+1)%sz]] = answer[circle[(j+1)%sz]][circle[j]] = 1; } } } } build(answer); 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...