Submission #1081897

#TimeUsernameProblemLanguageResultExecution timeMemory
1081897ALeonidouKeys (IOI21_keys)C++17
0 / 100
0 ms348 KiB
#include <bits/stdc++.h> #include "keys.h" using namespace std; #define ll int #define F first #define S second #define pb push_back #define sz(x) (ll)x.size() #define inf 1000000000 typedef vector <ll> vi; typedef pair <ll,ll> ii; typedef vector <ii> vii; #define dbg(x) cout<<#x<<": "<<x<<endl; #define dbg2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl; #define dbg3(x,y,z) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<" "<<#z<<": "<<z<<endl; void printVct(vi &v){ for (ll i =0; i<sz(v); i++){ cout<<v[i]<<" "; } cout<<endl; } vector <vi> adj; vi vis; ll dfs(ll u){ vis[u] = 1; ll c = 1; for (ll i =0; i<sz(adj[u]); i++){ if (!vis[adj[u][i]]){ c += dfs(adj[u][i]); } } return c; } vi find_reachable(vi r, vi u, vi v, vi c) { ll n = sz(r); ll m = sz(c); vi ans(n, 0); adj.assign(n, vi()); for(ll i =0; i<m; i++){ adj[u[i]].pb(v[i]); adj[v[i]].pb(u[i]); } vi connections(n); ll mini = inf; for (ll i =0; i<n; i++){ vis.assign(n, 0); connections[i] = dfs(i); mini = min(connections[i], mini); } // printVct(connections); for (ll i =0; i<n; i++){ ans[i] = (connections[i] == mini); } return ans; } /* 3 1 0 0 0 0 1 0 */
#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...