제출 #1068249

#제출 시각아이디문제언어결과실행 시간메모리
1068249Boas열쇠 (IOI21_keys)C++17
37 / 100
3067 ms34392 KiB
#include <bits/stdc++.h> using namespace std; typedef vector<int> vi; typedef vector<bool> vb; typedef vector<vi> vvi; typedef set<int> si; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<vii> vvii; #define pb push_back #define loop(x, i) for (int i = 0; i < x; i++) #define ALL(x) begin(x), end(x) #define sz(x) (int)x.size() vi find_reachable(vi r, vi u, vi v, vi c) { int n = sz(r); int m = sz(c); vvii adj(n); loop(m, i) { adj[u[i]].pb({v[i], c[i]}); adj[v[i]].pb({u[i], c[i]}); } vi cnt(n); loop(n, i) { si keys; vvi edgesPerKey(n); vb vis(n); auto addRoom = [&](auto &&self, int room) -> void { int key = r[room]; vis[room] = 1; cnt[i]++; if (!keys.count(key)) { keys.insert(key); for (int j : edgesPerKey[key]) { if (!vis[j]) self(self, j); } } for (auto [j, keyNeeded] : adj[room]) { if (vis[j]) continue; if (keys.count(keyNeeded)) { self(self, j); } else edgesPerKey[keyNeeded].pb(j); } }; addRoom(addRoom, i); } int min = *min_element(ALL(cnt)); vi ans(n); loop(n, i) if (cnt[i] == min) ans[i] = 1; return ans; }
#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...