Submission #671878

# Submission time Handle Problem Language Result Execution time Memory
671878 2022-12-14T07:32:31 Z a_aguilo Connecting Supertrees (IOI20_supertrees) C++14
0 / 100
1000 ms 14516 KB
#include<bits/stdc++.h>
#include "supertrees.h"

using namespace std;

int n;
vector<int> father;

int root(int node){
    if(father[node] == node) return node;
    return father[node] = root(father[node]);
}

int merge(int NodeA, int NodeB, vector<vector<int>> p){
    int rootA = root(NodeA);
    int rootB = root(NodeB);
    father[rootA] = rootB;
    for(int i = 0; i < n; ++i){
        if(i == rootA or i == rootB)continue;
        if(!(((p[rootA][i]) and (p[rootB][i])) or ((!p[rootA][i]) and (!p[rootB][i])))) return 0;
    }
    return 1;
}
int construct(vector<vector<int>> p){
    n = p[0].size();
    father = vector<int>(n);
    for(int i = 0; i < n; ++i) {
        father[i] = i;
    }
    for(int i = 0; i < n; ++i){
        for(int j = i+1; j < n; ++j){
            if(p[i][j]){
                int sol = merge(i, j, p);
                if(!sol) return 0;
            }else{
                for(int k = 0; k < n; ++k){
                    if(k == i or k==j) continue;
                    if(p[i][k] and p[j][k]) return 0;
                }
            }
        }
    }
    vector<vector<int>> edges(n, vector<int>(n, 0));
    for(int i = 0; i < n; ++i) {
        int MyRoot = root(i);
        if(MyRoot==i) continue;
        edges[MyRoot][i] = edges[i][MyRoot] = 1;
    }
    build(edges);
    return 1;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 0 ms 300 KB Output is correct
5 Correct 0 ms 296 KB Output is correct
6 Correct 440 ms 1404 KB Output is correct
7 Execution timed out 1082 ms 14516 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 0 ms 300 KB Output is correct
5 Correct 0 ms 296 KB Output is correct
6 Correct 440 ms 1404 KB Output is correct
7 Execution timed out 1082 ms 14516 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 1 ms 300 KB Answer gives possible 1 while actual possible 0
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 300 KB Output is correct
2 Incorrect 1 ms 304 KB Too few ways to get from 0 to 1, should be 2 found 1
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 0 ms 300 KB Output is correct
5 Correct 0 ms 296 KB Output is correct
6 Correct 440 ms 1404 KB Output is correct
7 Execution timed out 1082 ms 14516 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 0 ms 300 KB Output is correct
5 Correct 0 ms 296 KB Output is correct
6 Correct 440 ms 1404 KB Output is correct
7 Execution timed out 1082 ms 14516 KB Time limit exceeded
8 Halted 0 ms 0 KB -