Submission #1291626

#TimeUsernameProblemLanguageResultExecution timeMemory
1291626kahoulConnecting Supertrees (IOI20_supertrees)C++20
0 / 100
1 ms340 KiB
#include "supertrees.h" #include <bits/stdc++.h> using namespace std; const int maxn = 1e3 + 10; int parent[maxn]; int find (int u) { if (parent[u] == u) return u; return parent[u] = find(parent[u]); } void onion (int u, int v) { u = find(u); v = find (v); if (u == v) return; parent[max(u, v)] = min(u, v); } int construct(vector<vector<int>> p) { int n = p.size(); for (int i = 0; i < n; i++) { parent[i] = i; } vector<vector<int>> answer; for (int i = 0; i < n; i++) { vector<int> row(n, 0); answer.push_back(row); } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (p[i][j] == 1) { onion(i, j); } else { if (find(i) == find(j)) return 0; } } } for (int i = 0; i < n; i++) { answer[i][parent[i]] = 1; answer[parent[i]][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...