제출 #796177

#제출 시각아이디문제언어결과실행 시간메모리
796177t6twotwo열쇠 (IOI21_keys)C++17
37 / 100
3012 ms24476 KiB
#include "keys.h" #include <bits/stdc++.h> using namespace std; using ll = long long; vector<int> find_reachable(vector<int> R, vector<int> U, vector<int> V, vector<int> C) { int N = R.size(), M = C.size(); vector<vector<pair<int, int>>> adj(N); for (int i = 0; i < M; i++) { adj[U[i]].emplace_back(V[i], C[i]); adj[V[i]].emplace_back(U[i], C[i]); } vector<int> p(N); for (int i = 0; i < N; i++) { vector<bool> have(N), vis(N); vector<vector<int>> w(N); queue<int> q; vis[i] = 1; q.push(i); while (!q.empty()) { int x = q.front(); q.pop(); p[i]++; have[R[x]] = 1; for (int y : w[R[x]]) { if (!vis[y]) { vis[y] = 1; q.push(y); } } w[R[x]].clear(); for (auto [y, z] : adj[x]) { if (vis[y]) { continue; } if (have[z]) { vis[y] = 1; q.push(y); } else { w[z].push_back(y); } } } } int mn = *min_element(p.begin(), p.end()); vector<int> ans(N); for (int i = 0; i < N; i++) { if (p[i] == mn) { 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...