Submission #1213420

#TimeUsernameProblemLanguageResultExecution timeMemory
1213420Captain_GeorgiaEaster Eggs (info1cup17_eastereggs)C++20
0 / 100
1 ms500 KiB
#include "grader.h"

#include <bits/stdc++.h>
using namespace std;
 
int findEgg (int N, vector<pair<int, int>> edges) {
	  vector<int> g[N];
    for (auto [u, v] : edges) {
		    -- u; -- v;
        g[u].push_back(v);
        g[v].push_back(u);
    }

  	vector<int> ord;
  	function<void(int, int)> dfs = [&](int si, int pi) -> void {
  		ord.push_back(si);
  		for (auto ti : g[si]) if (ti != pi) {
  			dfs(ti, si);
  		}
  	};
    dfs(0, 0);

    int low = 0, high = N - 1, best = 0;
    while (low < high) {
        int mid = (low + high) / 2;
        vector<int> tmp;
        for(int i = 0;i <= mid;i ++) tmp.push_back(ord[i]);
        if (query(tmp) == 1) {
            high = mid;
        } else {
            low = mid + 1;
        }
    }
    return ord[low] + 1;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...