Submission #603043

#TimeUsernameProblemLanguageResultExecution timeMemory
603043FatihSolakKeys (IOI21_keys)C++17
37 / 100
3090 ms34740 KiB
#include <bits/stdc++.h> #define N 300005 using namespace std; bool keys[N]; bool vis[N]; vector<int> key_needed[N]; vector<int> adj[N]; vector<int> find_reachable(vector<int> r, vector<int> u, vector<int> v, vector<int> c) { int n = r.size(); int m = u.size(); vector<int> p(n,0); for(int i = 0;i<m;i++){ adj[u[i]].push_back(i); adj[v[i]].push_back(i); } for(int i = 0;i<n;i++){ for(int j = 0;j<n;j++){ keys[j] = 0; vis[j] = 0; key_needed[j].clear(); } queue<int> q; q.push(i); while(q.size()){ auto tp = q.front(); q.pop(); if(vis[tp])continue; vis[tp] = 1; p[i]++; keys[r[tp]] = 1; for(auto x:key_needed[r[tp]]){ if(!vis[u[x]]){ q.push(u[x]); } if(!vis[v[x]]){ q.push(v[x]); } } key_needed[r[tp]].clear(); for(auto x:adj[tp]){ if(keys[c[x]]){ if(!vis[u[x]]){ q.push(u[x]); } if(!vis[v[x]]){ q.push(v[x]); } } else{ key_needed[c[x]].push_back(x); } } } } int mini = 1e9; for(int i = 0;i<n;i++){ mini = min(mini,p[i]); } for(int i = 0;i<n;i++){ p[i] = p[i] == mini; } return p; }
#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...