Submission #834730

#TimeUsernameProblemLanguageResultExecution timeMemory
834730IS_RushdiKeys (IOI21_keys)C++17
9 / 100
3020 ms23660 KiB
#include <bits/stdc++.h> using namespace std; vector<int> find_reachable(vector<int> r, vector<int> u, vector<int> v, vector<int> c) { vector<int> ans(r.size(), 1); int n = r.size(); int m = u.size(); vector<vector<int>>a(n); vector<int>tmp(n); for(int i = 0; i < m; i++){ a[v[i]].push_back(u[i]); a[u[i]].push_back(v[i]); } int mn = 1e9; for(int i = 0; i < n; i++){ vector<bool>vis(n,0); queue<pair<int,bool>>q; q.push({i,0}); int c = 0; while(!q.empty()){ int node = q.front().first; bool can = q.front().second; q.pop(); if(vis[node]) continue; vis[node]=1; c++; if(r[node] == 0) can=1; if(can){ for(int to : a[node]){ q.push({to,can}); } } } tmp[i] = c; mn = min(mn,c); } for(int i = 0; i < n; i++){ if(tmp[i] == mn) ans[i] = 1; else ans[i] = 0; } 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...