# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
405044 | ly20 | Connecting Supertrees (IOI20_supertrees) | C++17 | 2 ms | 464 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "supertrees.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1123;
int comp[MAXN];
vector <int> grafo[MAXN];
int marc[MAXN];
int cmp;
//vector <int> grafo2[MAXN];
vector <int> cat;
int dfs(int v) {
marc[v] = 1;
comp[v] = cmp;
for(int i = 0; i < grafo[v].size(); i++) {
int viz = grafo[v][i];
if(marc[viz] == 1) continue;
dfs(viz);
}
}
int resp[MAXN][MAXN];
int rep[MAXN];
vector <int> cic;
vector <vector <int> > answer;
int construct(vector<vector<int>> p) {
int n = p.size();
vector<vector<int>> answer;
for(int i = 0; i < n; i++) {
comp[i] = i;
}
for(int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
if(p[i][j] == 1) {
grafo[i].push_back(j); grafo[j].push_back(i);
}
}
}
for(int i = 0; i < n; i++) {
if(marc[i] == 0) {
dfs(i);
cmp++;
}
}
for(int i = 0; i < cmp; i++) {
vector <int> ln;
for(int j = 0; j < n; j++) if(comp[j] == i) ln.push_back(j);
int m = ln.size();
for(int j = 0; j < m; j++) {
int cur = ln[j];
for(int k = j + 1; k < m; k++) {
int tst = ln[k];
if(p[cur][tst] != 1) {
return 0;
}
}
}
for(int j = 0; j < m - 1; j++) {
int pr = j + 1;
resp[ln[j]][ln[pr]] = 1;
resp[ln[pr]][ln[j]] = 1;
}
}
for (int i = 0; i < n; i++) {
vector<int> row;
for(int j = 0; j < n; j++) {
row.push_back(resp[i][j]);
}
answer.push_back(row);
}
build(answer);
return 1;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |