제출 #1063034

#제출 시각아이디문제언어결과실행 시간메모리
1063034vjudge1열쇠 (IOI21_keys)C++17
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> using namespace std; using vi = vector<int>; using ii = pair<int, int>; vector<vector<ii> > L; int dfs(int n, int m, int s, vi &r) { vi viz(n, 0); vector<vi> Locked(m); vi Q; Q.push_back(s); set<int> Cul; while(!Q.empty()) { int u = Q.back(); Q.pop_back(); if(!Cul.count(r[u])) { for(auto it : Locked[r[u]]) { if(!viz[it]) { viz[it] = 1; Q.push_back(it); } } Cul.insert(r[u]); } for(auto [c, to] : L[u]) { if(viz[to]) continue; if(Cul.count(c)) { viz[to] = 1; Q.push_back(to); } else { Locked[c].push_back(to); } } } int re = 0; for(auto it : viz) re += it; return re; } vi find_reachable(vi r, vi u, vi v, vi c) { int n = int(r.size()), m = int(u.size()); L.resize(n); for(int i = 0; i < m; ++i) { L[u[i]].push_back({c[i], v[i]}); L[v[i]].push_back({c[i], u[i]}); } vi nr; int mi = n; for(int i = 0; i < n; ++i) { nr.push_back(dfs(n, m, i, r)); mi = min(mi, nr.back()); } vi re; for(int i = 0; i < n; ++i) re.push_back(nr[i] == mi); return re; }
#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...