Submission #441900

# Submission time Handle Problem Language Result Execution time Memory
441900 2021-07-06T14:20:06 Z PiejanVDC Connecting Supertrees (IOI20_supertrees) C++17
0 / 100
1 ms 288 KB
#include "supertrees.h"
#include <bits/stdc++.h>
using namespace std;
void build(std::vector<std::vector<int>> _b);
vector<int>parent;

int uf(int p) {
    if(parent[p] == p) return p;
    return parent[p] = uf(parent[p]);
}

bool same(int u, int v) {
    if(uf(u) == uf(v)) {
        return true;
    }
    return false;
}

int construct(vector<vector<int>> p) {
    int n = p.size();
    parent.resize(n);
    for(int i = 0 ; i < n ; i++) {
        parent[i]=i;
    }
    vector<vector<int>>v(n,vector<int>(n,0));
    for(int i = 0 ; i < n-1 ; i++) {
        for(int j = i+1 ; j < n ; j++) {
            if(p[i][j]) {
                v[i][j]=1,v[j][i]=1;
                if(!same(i,j))
                    parent[j]=i;
            }
        }
    }
    for(int i = 0 ; i < n ; i++) {
        for(int j = i+1 ; j < n ; j++) {
            if(!p[i][j]) {
                if(same(i,j)) {
                    return 0;
                }
            }
        }
    }
    build(v);
    return 1;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Too many ways to get from 0 to 2, should be 1 found no less than 2
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Too many ways to get from 0 to 2, should be 1 found no less than 2
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 1 ms 204 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 204 KB Output is correct
2 Correct 0 ms 288 KB Output is correct
3 Incorrect 1 ms 204 KB Too many ways to get from 1 to 4, should be 1 found no less than 2
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Too many ways to get from 0 to 2, should be 1 found no less than 2
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Too many ways to get from 0 to 2, should be 1 found no less than 2
4 Halted 0 ms 0 KB -