제출 #609557

#제출 시각아이디문제언어결과실행 시간메모리
609557Ozy열쇠 (IOI21_keys)C++17
9 / 100
100 ms14572 KiB
#include <bits/stdc++.h> using namespace std; #define rep(i,a,b) for (int i = (a); i <= (b); i++) #define repa(i,a,b) for (int i = (a); i >= (b); i--) #define lli long long int #define debug(a) cout << #a << " = " << a << endl #define debugsl(a) cout << #a << " = " << a << ", " #define MAX 300000 #define padre first #define num second lli n,m,a; pair<lli,lli> uf[MAX+2]; lli sube(lli a) { if (uf[a].padre == a) return a; uf[a].padre = sube(uf[a].padre); return uf[a].padre; } void une(lli a ,lli b) { a = sube(a); b = sube(b); if (a==b) return; uf[b].padre = a; uf[a].num += uf[b].num; } std::vector<int> find_reachable(std::vector<int> r, std::vector<int> u, std::vector<int> v, std::vector<int> c) { n = r.size(); m = u.size(); rep(i,0,n-1) uf[i] = {i,1}; rep(i,0,m-1) une(u[i],v[i]); int peor = 1<<30; vector<int> res; res.resize(n,0); rep(i,0,n-1) { if (r[i] != 0) res[i] = 1; else { a = sube(i); res[i] = uf[a].num; } peor = min(res[i],peor); } rep(i,0,n-1) if (res[i] == peor) res[i] = 1; else res[i] = 0; return res; }
#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...