Submission #720628

# Submission time Handle Problem Language Result Execution time Memory
720628 2023-04-08T17:47:34 Z Toxtaq Connecting Supertrees (IOI20_supertrees) C++17
21 / 100
182 ms 22088 KB
#ifndef SUPERTREES_H_INCLUDED
#define SUPERTREES_H_INCLUDED
#include "supertrees.h"
#include<bits/stdc++.h>
using namespace std;
struct DSU{
    vector<int>par;
    DSU(int n){
        par.assign(n, -1);
    }
    int FindRep(int u){
        if(par[u] < 0)return u;
        return par[u] = FindRep(par[u]);
    }
    void Union(int u, int v){
        u = FindRep(u);
        v = FindRep(v);
        if(u == v)return;
        if(par[u] > par[v])swap(u, v);
        par[u] += par[v];
        par[v] = u;
    }
    bool IsConnected(int u, int v){
        u = FindRep(u);
        v = FindRep(v);
        return (u == v);
    }
};
void build(vector<vector<int>>b);
int construct(vector<vector<int>>p){
    int n = p.size();
    DSU dsu1(n);
    vector<vector<int>>b(n, vector<int>(n));
    for(int i = 0;i < n;++i){
        for(int j = 0;j < n;++j){
            if(p[i][j] && i != j){
                if(dsu1.IsConnected(i, j))continue;
                dsu1.Union(i, j);
                b[i][j] = b[j][i] = 1;
            }
        }
    }
    for(int i = 0;i < n;++i){
        for(int j = 0;j < n;++j){
            if(i != j && !p[i][j] && dsu1.IsConnected(i, j))return 0;
        }
    }
    build(b);
    return 1;
}


#endif // SUPERTREES_H_INCLUDED

# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 7 ms 1160 KB Output is correct
7 Correct 164 ms 22016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 7 ms 1160 KB Output is correct
7 Correct 164 ms 22016 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 7 ms 1108 KB Output is correct
13 Correct 161 ms 22028 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 4 ms 760 KB Output is correct
17 Correct 80 ms 12112 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 47 ms 5664 KB Output is correct
21 Correct 167 ms 22028 KB Output is correct
22 Correct 164 ms 21928 KB Output is correct
23 Correct 182 ms 22088 KB Output is correct
24 Correct 164 ms 22028 KB Output is correct
25 Correct 72 ms 12048 KB Output is correct
26 Correct 68 ms 12036 KB Output is correct
27 Correct 180 ms 22032 KB Output is correct
28 Correct 156 ms 21964 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 0 ms 212 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 212 KB Output is correct
2 Incorrect 0 ms 212 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 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 7 ms 1160 KB Output is correct
7 Correct 164 ms 22016 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 7 ms 1108 KB Output is correct
13 Correct 161 ms 22028 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 4 ms 760 KB Output is correct
17 Correct 80 ms 12112 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 47 ms 5664 KB Output is correct
21 Correct 167 ms 22028 KB Output is correct
22 Correct 164 ms 21928 KB Output is correct
23 Correct 182 ms 22088 KB Output is correct
24 Correct 164 ms 22028 KB Output is correct
25 Correct 72 ms 12048 KB Output is correct
26 Correct 68 ms 12036 KB Output is correct
27 Correct 180 ms 22032 KB Output is correct
28 Correct 156 ms 21964 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Incorrect 0 ms 212 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 7 ms 1160 KB Output is correct
7 Correct 164 ms 22016 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 7 ms 1108 KB Output is correct
13 Correct 161 ms 22028 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 4 ms 760 KB Output is correct
17 Correct 80 ms 12112 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 47 ms 5664 KB Output is correct
21 Correct 167 ms 22028 KB Output is correct
22 Correct 164 ms 21928 KB Output is correct
23 Correct 182 ms 22088 KB Output is correct
24 Correct 164 ms 22028 KB Output is correct
25 Correct 72 ms 12048 KB Output is correct
26 Correct 68 ms 12036 KB Output is correct
27 Correct 180 ms 22032 KB Output is correct
28 Correct 156 ms 21964 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Incorrect 0 ms 212 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -