답안 #720635

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
720635 2023-04-08T17:58:48 Z Toxtaq 슈퍼트리 잇기 (IOI20_supertrees) C++17
0 / 100
1 ms 356 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){
                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

# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Too many ways to get from 0 to 2, should be 1 found no less than 2
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Too many ways to get from 0 to 2, should be 1 found no less than 2
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 Incorrect 0 ms 212 KB Answer gives possible 1 while actual possible 0
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 356 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Too many ways to get from 1 to 4, should be 1 found no less than 2
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Too many ways to get from 0 to 2, should be 1 found no less than 2
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Too many ways to get from 0 to 2, should be 1 found no less than 2
4 Halted 0 ms 0 KB -