제출 #625069

#제출 시각아이디문제언어결과실행 시간메모리
625069cfalas슈퍼트리 잇기 (IOI20_supertrees)C++17
0 / 100
1 ms212 KiB
#include<bits/stdc++.h> #include "supertrees.h" #include <vector> using namespace std; typedef vector<int> vi; #define FORi(i,a,b) for(int i=((int)a);i<((int)b);i++) #define FOR(i,n) FORi(i,0,n) int par[10000]; int lef[10000]; int fnd(int a){ if(par[a]==a) return a; par[a] = fnd(par[a]); return par[a]; } void onion(int a, int b){ par[fnd(a)] = fnd(b); } int construct(vector<vector<int>> p) { int n = p.size(); FOR(i,n) par[i] = i; vector<std::vector<int>> adj(n, vi(n, 0)); int deg[n] = {}; FOR(i,n){ FOR(j,n){ if(i==j) continue; if(p[i][j] && fnd(i)!=fnd(j)){ onion(i, j); adj[i][j] = 1; adj[j][i] = 1; deg[i]++; deg[j]++; break; } else if(!p[i][j] && fnd(i)==fnd(j)){ return 0; } } } FOR(i,n){ if(deg[i]==1){ FOR(j,n) if(fnd(i)==fnd(j) && deg[j]==1 && i!=j){ deg[i]++; deg[j]++; adj[i][j] = 1; adj[j][i] = 1; } } } build(adj); 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...