Submission #385712

# Submission time Handle Problem Language Result Execution time Memory
385712 2021-04-04T19:18:45 Z AlexRex0 Connecting Supertrees (IOI20_supertrees) C++14
21 / 100
290 ms 22372 KB
#include "supertrees.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;

int n;
int link[1002];
int setSize[1002];

void init(){
    for(int i = 0; i < n; ++i){
        link[i] = i;
        setSize[i] = 1;
    }
}

int root(int u){
    if(link[u] == u){
        return u;
    }else{
        link[u] = root(link[u]);
        return link[u];
    }
}

bool same(int u, int v){
    int rU = root(u);
    int rV = root(v);
    return rU == rV;
}

void unite(int u, int v){
    u = root(u);
    v = root(v);
    if(setSize[v] > setSize[u]){
        swap(u,v);
    }
    setSize[u] += setSize[v];
    link[v] = u;
}


int construct(vector< vector<int> > p) {
	n = p.size();
	vector< vector <int> > answer;
	for(int i = 0; i < n; ++i){
        vector<int> aux(n, 0);
        answer.push_back(aux);
	}
	init();
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j){
            if(p[i][j] == 1 && !same(i, j)){
                unite(i, j);
                answer[i][j] = 1;
                answer[j][i] = 1;
            }
        }
    }
    bool valido = true;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j){
            if(p[i][j] == 0 && same(i, j)){
                valido = false;
            }
        }
    }
    if(valido){
        build(answer);
        return 1;
    }else{
        return 0;
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 11 ms 1260 KB Output is correct
7 Correct 256 ms 22144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 11 ms 1260 KB Output is correct
7 Correct 256 ms 22144 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 11 ms 1260 KB Output is correct
13 Correct 290 ms 22124 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 6 ms 748 KB Output is correct
17 Correct 140 ms 12268 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 67 ms 5868 KB Output is correct
21 Correct 261 ms 22116 KB Output is correct
22 Correct 268 ms 22372 KB Output is correct
23 Correct 278 ms 22124 KB Output is correct
24 Correct 268 ms 22124 KB Output is correct
25 Correct 119 ms 12140 KB Output is correct
26 Correct 117 ms 12140 KB Output is correct
27 Correct 275 ms 22124 KB Output is correct
28 Correct 259 ms 22124 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 1 ms 364 KB Answer gives possible 1 while actual possible 0
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Too few ways to get from 0 to 1, should be 2 found 0
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 11 ms 1260 KB Output is correct
7 Correct 256 ms 22144 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 11 ms 1260 KB Output is correct
13 Correct 290 ms 22124 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 6 ms 748 KB Output is correct
17 Correct 140 ms 12268 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 67 ms 5868 KB Output is correct
21 Correct 261 ms 22116 KB Output is correct
22 Correct 268 ms 22372 KB Output is correct
23 Correct 278 ms 22124 KB Output is correct
24 Correct 268 ms 22124 KB Output is correct
25 Correct 119 ms 12140 KB Output is correct
26 Correct 117 ms 12140 KB Output is correct
27 Correct 275 ms 22124 KB Output is correct
28 Correct 259 ms 22124 KB Output is correct
29 Correct 2 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Incorrect 1 ms 364 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 11 ms 1260 KB Output is correct
7 Correct 256 ms 22144 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 11 ms 1260 KB Output is correct
13 Correct 290 ms 22124 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 6 ms 748 KB Output is correct
17 Correct 140 ms 12268 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 67 ms 5868 KB Output is correct
21 Correct 261 ms 22116 KB Output is correct
22 Correct 268 ms 22372 KB Output is correct
23 Correct 278 ms 22124 KB Output is correct
24 Correct 268 ms 22124 KB Output is correct
25 Correct 119 ms 12140 KB Output is correct
26 Correct 117 ms 12140 KB Output is correct
27 Correct 275 ms 22124 KB Output is correct
28 Correct 259 ms 22124 KB Output is correct
29 Correct 2 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Incorrect 1 ms 364 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -