Submission #1049209

#TimeUsernameProblemLanguageResultExecution timeMemory
1049209amine_arouaKeys (IOI21_keys)C++17
9 / 100
3052 ms23696 KiB
#include <bits/stdc++.h> using namespace std; int n ; vector<vector<pair<int, int>>> adj; vector<int> r; std::vector<int> find_reachable(std::vector<int> r_, std::vector<int> u, std::vector<int> v, std::vector<int> c) { n = (int)r_.size(); r = r_; adj.assign(n , {}); for(int i = 0 ; i < (int)u.size() ; i++) { adj[u[i]].push_back({v[i] , c[i]}); adj[v[i]].push_back({u[i] , c[i]}); } vector<bool> reach(n); vector<int> p(n); int mn = 1e9; for(int i = 0 ; i < n ;i++) { reach = vector<bool>(n); vector<int> wait[n]; wait[r[i]].push_back(i); int x = r[i]; while(true) { if(wait[x].empty()) { break; } int node = wait[x].back(); wait[x].pop_back(); reach[node] = 1; for(auto [u , key] : adj[node]) { if(!reach[u]) { wait[key].push_back(u); } } x = r[node]; } for(int j = 0 ; j < n ; j++) { p[i]+=reach[j]; } mn = min(mn , p[i]); } vector<int> ret(n); for(int i = 0 ; i < n ;i++) { ret[i] = (p[i] == mn); } 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...