Submission #970263

#TimeUsernameProblemLanguageResultExecution timeMemory
970263mychecksedadKeys (IOI21_keys)C++17
37 / 100
3048 ms37488 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define all(x) x.begin(), x.end() #define en cout << '\n'; #define ll long long int const int N = 3e5+10; vector<pair<int, int>> g[N]; vector<int> K[N]; 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); int n = r.size(), m = U.size(); vector<int> p(n); for(int i = 0; i < m; ++i){ g[U[i]].pb({V[i], c[i]}); g[V[i]].pb({U[i], c[i]}); } for(int i = 0; i < n; ++i){ for(int j = 0; j < n; ++j) K[j].clear(); vector<bool> vis(n), has(n); vis[i] = 1; queue<int> q; q.push(i); while(!q.empty()){ int v = q.front(); q.pop(); if(has[r[v]] == 0){ for(auto u: K[r[v]]){ if(vis[u]) continue; vis[u] = 1; q.push(u); } K[r[v]].clear(); } has[r[v]] = 1; for(auto U: g[v]){ int u = U.first, key = U.second; if(!vis[u]){ if(has[key]){ vis[u] = 1; q.push(u); }else{ K[key].pb(u); } } } } for(int j = 0; j < n; ++j) if(vis[j]) ++p[i]; } int mn = *min_element(all(p)); for(int i = 0; i < n; ++i) ans[i] = p[i] == mn; 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...