Submission #230507

#TimeUsernameProblemLanguageResultExecution timeMemory
230507zoooma13Easter Eggs (info1cup17_eastereggs)C++14
100 / 100
36 ms384 KiB
#include <bits/stdc++.h> #include "grader.h" using namespace std; #define MAX_N 513 vector <int> adj[MAX_N] ,active ,Set; int SZ; void dfs(int u ,int p=-1){ if(!SZ) return; Set.push_back(u); if(find(active.begin() ,active.end() ,u) != active.end()) SZ--; for(int&v : adj[u]) if(v != p) dfs(v ,u); } vector <int> findSet(int sz){ SZ = sz; Set.clear(); dfs(1); return Set; } int findEgg (int N, vector < pair < int, int > > bridges){ active.clear(); for(int i=0; i<=N; i++) adj[i].clear(); for(auto&e : bridges) adj[e.first].push_back(e.second), adj[e.second].push_back(e.first); active.resize(N); iota(active.begin() ,active.end() ,1); while(active.size() > 1){ vector <int> vs = findSet(((int)active.size())/2); if(query(vs)){ vector <int> nv; for(int&v : vs) if(find(active.begin() ,active.end() ,v) != active.end()) nv.push_back(v); active = nv; }else{ for(int&v : vs) if(find(active.begin() ,active.end() ,v) != active.end()) active.erase(find(active.begin() ,active.end() ,v)); } } return active.front(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...