# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
953751 | 2024-03-26T15:29:01 Z | Trisanu_Das | Connecting Supertrees (IOI20_supertrees) | C++17 | 1 ms | 600 KB |
#include <bits/stdc++.h> using namespace std; #include "supertrees.h" int n, par[1005]; int find(int u){ if(par[u] == u) return u; par[u] = find(par[u]); return par[u]; } void union_(int u, int v){ par[find(u)] = find(v); } int construct(vector<vector<int> > p){ n = p.size(); for(int i = 0; i < n; i++) par[i] = i; vector<vector<int> > b(n, vector<int>(n)); for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ if(p[i][j] && find(i) != find(j)){ union_(i, j); b[i][j] = b[j][i] = 1; }else if(!p[i][j] && find(i) == find(j)) return 0; } } for(int i = 0; i < n; i++){ vector<int> v; v.push_back(par[i]); for(int j = i + 1; j < n; j++){ if(p[i][j] == 2 && find(i) != find(j)){ v.push_back(par[j]); union_(i, j); } } if(v.size() == 2) return 0; for(int k = 0; k + 1 < v.size(); k++) b[v[k]][v[k + 1]] = b[v[k + 1]][v[k]] = 1; b[v[0]][v[v.size() - 1]] = b[v[v.size() - 1]][v[0]] = 1; } build(b); return 1; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 600 KB | b[0][0] is not 0 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 600 KB | b[0][0] is not 0 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | b[0][0] is not 0 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | b[0][0] is not 0 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 600 KB | b[0][0] is not 0 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 600 KB | b[0][0] is not 0 |
2 | Halted | 0 ms | 0 KB | - |