Submission #817028

#TimeUsernameProblemLanguageResultExecution timeMemory
817028aVeKeys (IOI21_keys)C++17
9 / 100
3072 ms451328 KiB
#include <bits/stdc++.h> //#include "grader.cpp" using namespace std; #define pb push_back #define mp make_pair typedef long long ll; typedef pair<int,int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vl; int n, m; vector<pii> G[100100]; vi find_reachable(vi r, vi u, vi v, vi c) { n = (int)r.size(); m = (int)c.size(); vi reach(n, 0); for(int i = 0; i < (int)u.size(); i++){ G[u[i]].pb(mp(v[i], c[i])); G[v[i]].pb(mp(u[i], c[i])); } for(int room = 0; room < n; room++){ queue<pair<int, vector<bool>>> q; vector<bool> ini(n, false); bool vis[n]; memset(vis, false, sizeof vis); vis[room] = true; ini[r[room]] = true; q.push(mp(room, ini)); while(!q.empty()){ int at = q.front().first; vector<bool> ava = q.front().second; if(!ava[r[at]]) ava[r[at]] = true; q.pop(); for(auto next : G[at]){ if(ava[next.second] && !vis[next.first]){ vis[next.first] = true; q.push(mp(next.first, ava)); } } } int cnt = 0; for(int i = 0; i < n; i++){ if(vis[i]) cnt++; } reach[room] = cnt; } int sm = *min_element(reach.begin(), reach.end()); vi ans(n, 0); for(int i = 0; i < n; i++){ if(reach[i] == sm) 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...