제출 #1048245

#제출 시각아이디문제언어결과실행 시간메모리
1048245LittleOrangeSimurgh (IOI17_simurgh)C++17
13 / 100
14 ms436 KiB
#include "simurgh.h" #include<bits/stdc++.h> using namespace std; using ll = int; struct dsu{ ll n; vector<ll> p; dsu(ll N):n(N),p(N,-1){} ll g(ll i){ return p[i]<0?i:p[i] = g(p[i]); } bool m(ll a, ll b){ a = g(a); b = g(b); if(a==b) return false; if (p[a]>p[b]) swap(a,b); p[a] += p[b]; p[b] = a; return true; } }; std::vector<int> find_roads(int n, std::vector<int> u, std::vector<int> v) { ll m = u.size(); if (m<=28){ for(ll j = 0;j<(1<<m);j++) if(__builtin_popcount(j)==n-1){ vector<ll> r; for(ll i = 0;i<m;i++) if(j>>i&1) r.push_back(i); dsu d(n); ll ok = 1; for(ll i : r){ if(!d.m(u[i],v[i]))ok = 0; } if(ok){ ll g = count_common_roads(r); if (g==n-1){ return r; } } } } std::vector<int> r(n - 1); for(int i = 0; i < n - 1; i++) r[i] = i; int common = count_common_roads(r); if(common == n - 1) return r; r[0] = n - 1; return r; }
#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...