답안 #524233

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
524233 2022-02-08T20:27:11 Z CSQ31 Easter Eggs (info1cup17_eastereggs) C++17
100 / 100
20 ms 360 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;

vector<int>adj[1000],a;
void dfs(int v,int u){
	a.push_back(v);
	for(int x:adj[v]){
		if(x==u)continue;
		dfs(x,v);
	}
}
int findEgg (int n, vector < pair < int, int > > bridges)
{
	a.clear();
	for(int i=1;i<=n;i++)adj[i].clear();
	for(auto x:bridges){
		adj[x.first].push_back(x.second);
		adj[x.second].push_back(x.first);
	}
	dfs(1,0);
	int l = 0,r = n-1;
	while(r>l){
		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];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Number of queries: 4
2 Correct 1 ms 200 KB Number of queries: 4
3 Correct 1 ms 200 KB Number of queries: 4
4 Correct 1 ms 200 KB Number of queries: 4
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 348 KB Number of queries: 8
2 Correct 11 ms 344 KB Number of queries: 9
3 Correct 13 ms 344 KB Number of queries: 9
4 Correct 14 ms 356 KB Number of queries: 9
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 360 KB Number of queries: 9
2 Correct 14 ms 328 KB Number of queries: 9
3 Correct 13 ms 328 KB Number of queries: 9
4 Correct 14 ms 328 KB Number of queries: 9