# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
314066 | 2020-10-18T05:16:37 Z | linear00000 | Connecting Supertrees (IOI20_supertrees) | C++14 | 1 ms | 384 KB |
#include "supertrees.h" #include <bits/stdc++.h> using namespace std; vector<vector<int> > d; vector<int> C[1004]; int par[1004], num = 0; int findpar(int N) { if (N == par[N]) return N; else return par[N] = findpar(par[N]); } void merge(int a, int b) { int aa = findpar(a), bb = findpar(b); par[aa] = bb; } int construct(vector<vector<int> > v) { int n = v.size(); for (int i = 0; i < n; i++) par[i] = i; d.resize(n); for (int i = 0; i < n; i++) d[i].resize(n); for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (v[i][j] == 1 && i != j) merge(i, j); } } for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (v[i][j] == 0) { if (findpar(i) == findpar(j)) return 0; } } } for (int i = 0; i < n; i++) par[i] = findpar(i); for (int i = 0; i < n; i++) C[par[i]].push_back(i); for (int i = 0; i < n; i++) { for (int j = 0; j < C[i].size(); j++) { if (C[i][j] != i) d[i][C[i][j]] = 1, d[C[i][j]][i] = 1; } } for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (v[i][j] == 2 && i != j) merge(i, j); } } for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (v[i][j] == 0) { if (findpar(i) == findpar(j)) return 0; } } } for (int i = 0; i < n; i++) par[i] = findpar(i); for (int i = 0; i < n; i++) C[par[i]].push_back(i); for (int i = 0; i < n; i++) { int cnt = 0; if (C[i].size() == 2) return 0; else if (C[i].size() >= 3) { for (int j = 0; j < C[i].size() - 1; j++) { d[C[i][j]][C[i][j + 1]] = 1, d[C[i][j + 1]][C[i][j]] = 1; } d[C[i][C[i].size() - 1]][C[i][0]] = 1, d[C[i][0]][C[i][C[i].size() - 1]] = 1; } } for (int i=0; i<n; i++) C[i].clear(); build(d); return 1; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 384 KB | Answer gives possible 0 while actual possible 1 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 384 KB | Answer gives possible 0 while actual possible 1 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 384 KB | Answer gives possible 0 while actual possible 1 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 384 KB | Answer gives possible 0 while actual possible 1 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 384 KB | Answer gives possible 0 while actual possible 1 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 384 KB | Answer gives possible 0 while actual possible 1 |
2 | Halted | 0 ms | 0 KB | - |