Submission #733281

#TimeUsernameProblemLanguageResultExecution timeMemory
733281ismayilConnecting Supertrees (IOI20_supertrees)C++17
0 / 100
1157 ms2097152 KiB
#include "supertrees.h" #include <bits/stdc++.h> using namespace std; const int MAX = 1e3 + 3; int par[MAX]; int find(int u){ if(par[u] < 0) return u; return par[u] = find(par[u]); } bool unite(int u, int v){ u = find(u), v = find(v); if(u == v) return false; if(par[u] > par[v]) swap(u, v); par[u] += par[v]; par[v] = u; return true; } int construct(vector<vector<int>> p) { int n = p.size(); vector<vector<int>> answer(n, vector<int>(n, 0)); for (int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ if(!p[i][j]) continue; if(unite(i, j)){ answer[i][j] = answer[j][i] = 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...