Submission #918220

# Submission time Handle Problem Language Result Execution time Memory
918220 2024-01-29T13:36:41 Z vjudge1 Easter Eggs (info1cup17_eastereggs) C++17
100 / 100
15 ms 988 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
int cnt=0;
vector<vector<int>> g;
vector<int> a;
void dfs(int v,int prev){
	a.push_back(v);
	for(auto x:g[v]){
		if(x==prev){
			continue;
		}
		dfs(x,v);
	}
}
int findEgg (int N, vector < pair < int, int > > bridges)
{
	g.clear();
	a.clear();
	g.resize(N+1);
	for(auto x:bridges){
		g[x.first].push_back(x.second); 
		g[x.second].push_back(x.first);
	}
	dfs(1,-1);
	int l=1,r=N; 
	while(l<r){
		int mid=(l+r)/2; 
		vector<int> b;
		for(int i=0;i<mid;i++){
			b.push_back(a[i]);
		}
		if(query(b)){
			r=mid; 
		}
		else{
			l=mid+1;
		}
	}
    return a[r-1];
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Number of queries: 4
2 Correct 1 ms 344 KB Number of queries: 4
3 Correct 1 ms 344 KB Number of queries: 4
4 Correct 1 ms 344 KB Number of queries: 4
# Verdict Execution time Memory Grader output
1 Correct 3 ms 724 KB Number of queries: 8
2 Correct 8 ms 728 KB Number of queries: 9
3 Correct 12 ms 988 KB Number of queries: 9
4 Correct 12 ms 748 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Correct 15 ms 752 KB Number of queries: 9
2 Correct 10 ms 988 KB Number of queries: 9
3 Correct 14 ms 988 KB Number of queries: 9
4 Correct 11 ms 744 KB Number of queries: 9