Submission #428324

#TimeUsernameProblemLanguageResultExecution timeMemory
428324MarcoMeijer슈퍼트리 잇기 (IOI20_supertrees)C++14
21 / 100
279 ms24068 KiB
#include "supertrees.h" #include <bits/stdc++.h> using namespace std; // macros typedef long long ll; typedef long double ld; typedef pair<int, int> ii; typedef pair<ll, ll> lll; typedef tuple<int, int, int> iii; typedef vector<int> vi; typedef vector<ii> vii; typedef vector<iii> viii; typedef vector<ll> vll; typedef vector<lll> vlll; #define REP(a,b,c) for(int a=int(b); a<int(c); a++) #define RE(a,c) REP(a,0,c) #define RE1(a,c) REP(a,1,c+1) #define REI(a,b,c) REP(a,b,c+1) #define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--) #define FOR(a,b) for(auto& a : b) #define all(a) a.begin(), a.end() #define INF 1e9 #define EPS 1e-9 #define pb push_back #define popb pop_back #define fi first #define se second #define sz size() mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); const int MX=2000; int n; int p[MX], r[MX]; void buildDsu() { RE(i,n) p[i]=i, r[i]=0; } int getSet(int i) {return i==p[i] ? i : p[i]=getSet(p[i]);} bool isSameSet(int i, int j) {return getSet(i) == getSet(j);} void unionSet(int i, int j) { i = getSet(i), j = getSet(j); if(i != j) { if(r[i] > r[j]) { p[j] = i; } else { p[i] = j; if(r[i] == r[j]) r[j]++; } } } int construct(vector<vi> p) { n = p.size(); vector<vi> answer(n,vi(n,0)); buildDsu(); RE(i,n) RE(j,n) { if(p[i][j] == 1 && !isSameSet(i,j)) unionSet(i,j), answer[i][j] = answer[j][i] = 1; } RE(i,n) RE(j,n) if(p[i][j] == 0 && isSameSet(i,j)) return 0; 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...