Submission #551202

#TimeUsernameProblemLanguageResultExecution timeMemory
551202krit3379Easter Eggs (info1cup17_eastereggs)C++17
100 / 100
18 ms620 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=l;i<=mid;i++)v.push_back(id[i]); flag=query(v); if(flag){ for(i=l;i<=mid;i++)v.pop_back(); r=mid; } else{ l=mid+1; } } return id[r]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...