## Submission #314049

# Submission time Handle Problem Language Result Execution time Memory
314049 2020-10-18T01:34:15 Z linear00000 Connecting Supertrees (IOI20_supertrees) C++14
0 / 100
1 ms 512 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] == 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;
for (int j=0; j<C[i].size() - 1; j++) {
if (C[i][j] != i) cnt++;
d[C[i][j]][C[i][j + 1]] = 1, d[C[i][j + 1]][C[i][j]] = 1;
}
if (C[i][C[i].size() - 1] != i) cnt++;
if (cnt == 1) return 0;
}

build(d);
return 1;
}```

### Compilation message

```supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:42:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
42 |   for (int j=0; j<C[i].size() - 1; j++) {
|                 ~^~~~~~~~~~~~~~~~```

#### Subtask #1 0 / 11.0

# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 1 ms 384 KB Too few ways to get from 0 to 1, should be 1 found 0
3 Halted 0 ms 0 KB -

#### Subtask #2 0 / 10.0

# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 1 ms 384 KB Too few ways to get from 0 to 1, should be 1 found 0
3 Halted 0 ms 0 KB -

#### Subtask #3 0 / 19.0

# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 416 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Runtime error 1 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Halted 0 ms 0 KB -

#### Subtask #4 0 / 35.0

# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Runtime error 1 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -

#### Subtask #5 0 / 21.0

# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 1 ms 384 KB Too few ways to get from 0 to 1, should be 1 found 0
3 Halted 0 ms 0 KB -

#### Subtask #6 0 / 4.0

# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 1 ms 384 KB Too few ways to get from 0 to 1, should be 1 found 0
3 Halted 0 ms 0 KB -