Submission #1113019

#TimeUsernameProblemLanguageResultExecution timeMemory
1113019SalihSahinSimurgh (IOI17_simurgh)C++14
0 / 100
77 ms4428 KiB
#include <bits/stdc++.h> #define pb push_back #include "simurgh.h" using namespace std; const int MAXN = 5e2 + 5; vector<int> par(MAXN); vector<pair<int, int> > adj[MAXN]; int fnd(int a){ if(a == par[a]) return a; return par[a] = fnd(par[a]); } void merge(int a, int b){ a = fnd(a), b = fnd(b); par[b] = a; } vector<int> find_roads(int n, vector<int> u, vector<int> v) { vector<int> r; int m = u.size(); vector<int> ok(m); for(int i = 0; i < m; i++){ adj[u[i]].pb({v[i], i}); adj[v[i]].pb({u[i], i}); } for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ par[j] = j; } vector<int> ottree; for(int j = 0; j < n; j++){ if(j == i) continue; for(auto itr: adj[j]){ if(itr.first == i) continue; if(fnd(j) == fnd(itr.first)) continue; ottree.pb(itr.second); merge(j, itr.first); } } vector<pair<int, int> > vals; int mx = 0; for(auto itr: adj[i]){ ottree.pb(itr.second); int cnt = count_common_roads(ottree); vals.pb({cnt, itr.second}); mx = max(mx, cnt); ottree.pop_back(); } for(auto itr: vals){ if(itr.first == mx){ ok[itr.second] = 1; } } } for(int i = 0; i < m; i++){ if(ok[i]) r.pb(i); } return r; }
#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...