제출 #829587

#제출 시각아이디문제언어결과실행 시간메모리
829587Abrar_Al_Samit열쇠 (IOI21_keys)C++17
0 / 100
0 ms212 KiB
#include <bits/stdc++.h> #include "keys.h" using namespace std; const int nax = 200; vector<pair<int,int>>g[nax]; vector<int> find_reachable(vector<int> r, vector<int> u, vector<int> v, vector<int> c) { int n = r.size(), m = u.size(); for(int i=0; i<m; ++i) { g[u[i]].emplace_back(v[i], c[i]); g[v[i]].emplace_back(u[i], c[i]); } int cnt[n] = {0}; for(int sc=0; sc<n; ++sc) { bool rc[n] = {0}; rc[sc] = 1; bool key[n] = {0}; key[r[sc]] = 1; while(1) { bool none = true; for(int i=0; i<n; ++i) if(rc[i]) { for(auto [to ,type] : g[i]) { if(key[type] && !rc[to]) { rc[to] = 1; key[r[to]] = 1; none = false; } } } if(none) break; } for(int i=0; i<n; ++i) { cnt[sc] += rc[i]; } } int mn = 1e9; for(int i=0; i<n; ++i) { mn = min(mn, cnt[i]); } vector<int>ret; for(int i=0; i<n; ++i) if(cnt[i]==mn) { ret.push_back(i); } return ret; }
#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...