Submission #435447

#TimeUsernameProblemLanguageResultExecution timeMemory
435447Maqsut_03Keys (IOI21_keys)C++17
9 / 100
105 ms17176 KiB
#include<bits/stdc++.h> #define ll long long #define ff first #define ss second using namespace std; const int N = 2222; vector<pair<int, int> > g[N]; int n, m; std::vector<int> find_reachable(std::vector<int> r, std::vector<int> u, std::vector<int> v, std::vector<int> c) { std::vector<int> ans(r.size(), 1); n = r.size(); m = u.size(); for (int i=0; i<m; i++) { g[v[i]].push_back({u[i], c[i]}); g[u[i]].push_back({v[i], c[i]}); } queue<int> s; int k[N]; for (int i=0; i<n; i++) { vector<bool> used(n, false), keys(n, false); queue<int> q; q.push(i); used[i] = true; keys[r[i]] = true; k[i] = 0; while (!q.empty()){ int x = q.front(); k[i]++; q.pop(); for (auto e : g[x]){ int y = e.ff, C = e.ss; if (keys[C] && !used[y]){ used[y] = true; keys[r[y]] = true; q.push(y); } } } } int mn = N; for (int i=0; i<n; i++) mn = min(k[i], mn); for (int i=0; i<n; i++){ if (k[i] != mn) ans[i] = 0; } return ans; } /** 4 5 0 1 1 2 0 1 0 0 2 0 1 2 1 1 3 0 3 1 2 */
#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...