제출 #416416

#제출 시각아이디문제언어결과실행 시간메모리
416416ioi슈퍼트리 잇기 (IOI20_supertrees)C++14
0 / 100
1 ms296 KiB
#include "supertrees.h" #include <vector> #include<bits/stdc++.h> using namespace std ; const int N = 1002; int dsu[N] , sz[N]; int get(int u){ if(u == dsu[u]) return u ; return dsu[u] = get(dsu[u]); } void connect(int u , int v){ u = get(u) , v = get(v); if(u == v)return ; if(sz[u] > sz[v])swap(u , v); sz[v] += sz[u]; dsu[u] = v ; } bool same(int u , int v){ u = get(u) , v = get(v); return u == v ; } int construct(vector<vector<int>> p) { int n = p.size(); vector<vector<int>> answer (n , vector<int> (n , 0)); for(int i = 0 ; i < n ; i ++)sz[i] = 1 , dsu[i] = i ; for(int i = 0 ; i < n ; i ++){ for(int j = 0 ; j < n ; j ++){ if(p[i][j])connect(i , j); } } for(int i = 0 ; i < n ; i ++){ for(int j = 0 ; j < n ;j ++) { if(p[i][j] == 0&& same(i , j))return 0 ; if(p[i][j] && i != j)answer[i][j] = 1 , answer[j][i] = 1 ; } } build(answer); return 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...