Submission #1028868

#TimeUsernameProblemLanguageResultExecution timeMemory
1028868parsadox2Simurgh (IOI17_simurgh)C++17
0 / 100
61 ms3972 KiB
#include "simurgh.h" #include <bits/stdc++.h> using namespace std; const int N = 5e2 + 10; struct EDGE{ int to , id; }; int n , m; vector <EDGE> adj[N]; vector <int> r; bool marked[N] , dead[N]; int Find_good(int v) { marked[v] = true; for(auto u : adj[v]) if(!marked[u.to]) return Find_good(u.to); return v; } void Dfs(int v) { marked[v] = true; for(auto u : adj[v]) if(!marked[u.to] && !dead[u.to]) { r.push_back(u.id); Dfs(u.to); } } vector<int> find_roads(int nn, vector<int> u, vector<int> v) { n = nn; m = u.size(); for(int i = 0 ; i < m ; i++) { adj[u[i]].push_back({v[i] , i}); adj[v[i]].push_back({u[i] , i}); } int star = Find_good(0); vector <int> cand; dead[star] = true; cand.push_back(star); vector <int> cor; //cout << "STAR " << star << endl; while(!cand.empty()) { int mx = 0; vector <EDGE> add; r = cor; for(int i = 0 ; i < n ; i++) marked[i] = false; for(int i = 0 ; i < n ; i++) if(!dead[i]) { Dfs(i); break; } for(auto v : cand) for(auto u : adj[v]) if(!dead[u.to]) { r.push_back(u.id); //for(auto u : r) // cout << u << " "; //cout << " ? " << endl; int now = count_common_roads(r); //cout << now << endl; if(now > mx) { mx = now; add.clear(); } if(now == mx) add.push_back(u); r.pop_back(); } cand.clear(); for(auto u : add) { cor.push_back(u.id); dead[u.to] = true; cand.push_back(u.to); } } return cor; }
#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...