Submission #551200

#TimeUsernameProblemLanguageResultExecution timeMemory
551200krit3379Easter Eggs (info1cup17_eastereggs)C++17
100 / 100
23 ms468 KiB
#include<bits/stdc++.h> using namespace std; #include"grader.h" #define N 1000 int id[N],sz; vector<int> g[N]; void dfs(int s,int f){ id[++sz]=s; for(auto x:g[s]){ if(x==f)continue; dfs(x,s); } } int findEgg(int n, vector<pair<int,int>> edge){ int i,l,r,mid,flag; for(i=1;i<=n;i++)g[i].clear(); for(auto [a,b]:edge){ g[a].push_back(b); g[b].push_back(a); } sz=0; dfs(1,0); vector<int> v; l=1,r=n; while(l<r){ mid=(l+r)/2; for(i=1;i<=mid;i++)v.push_back(id[i]); flag=query(v); if(flag)r=mid; else l=mid+1; v.clear(); } return id[r]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...