# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
733289 | 2023-04-30T11:47:54 Z | ismayil | Connecting Supertrees (IOI20_supertrees) | C++17 | 1 ms | 212 KB |
#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) { memset(par, -1, sizeof(par)); int n = p.size(); vector<vector<int>> answer(n, vector<int>(n, 0)); int mark[n] = {0}; for (int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ if(p[i][j] == 2){ unite(i, j); } } } for(int i = 0; i < n; i++){ if(mark[find(i)]) continue; mark[find(i)] = 1; vector<int> v; for(int j = 0; j < n; j++){ if(find(i) == find(j)){ v.push_back(j); } } for(int j = 0; j < v.size() - 1; j++) answer[v[j]][v[j + 1]] = 1; answer[v[v.size() - 1]][v[0]] = 1; } build(answer); return 1; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 212 KB | b[0][0] is not 0 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 212 KB | b[0][0] is not 0 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | b[0][0] is not 0 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | b[0][0] is not 0 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 212 KB | b[0][0] is not 0 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 212 KB | b[0][0] is not 0 |
2 | Halted | 0 ms | 0 KB | - |