답안 #900053

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
900053 2024-01-07T14:05:42 Z pcc Easter Eggs (info1cup17_eastereggs) C++14
100 / 100
12 ms 1016 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;

const int mxn = 909;
vector<int> tree[mxn];
vector<int> v;
int n;

void dfs(int now,int par){
	v.push_back(now);
	for(auto nxt:tree[now]){
		if(nxt == par)continue;
		dfs(nxt,now);
	}
	return;
}

inline bool check(int tar){
	vector<int> vv;
	for(int i = 0;i<=tar;i++)vv.push_back(v[i]);
	return query(vv);
}

int findEgg (int N, vector < pair < int, int > > bridges){
	for(int i = 0;i<=n;i++)tree[i].clear();
	v.clear();
	n = N;
	for(auto &i:bridges){
		tree[i.first].push_back(i.second);
		tree[i.second].push_back(i.first);
	}
	dfs(1,1);
	int l = 0,r = n-1;
	while(l != r){
		int mid = (l+r)>>1;
		if(check(mid))r = mid;
		else l = mid+1;
	}
	return v[l];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Number of queries: 4
2 Correct 1 ms 344 KB Number of queries: 4
3 Correct 0 ms 344 KB Number of queries: 4
4 Correct 1 ms 344 KB Number of queries: 4
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 488 KB Number of queries: 8
2 Correct 7 ms 1004 KB Number of queries: 9
3 Correct 11 ms 748 KB Number of queries: 9
4 Correct 10 ms 764 KB Number of queries: 9
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 776 KB Number of queries: 9
2 Correct 12 ms 960 KB Number of queries: 9
3 Correct 10 ms 1008 KB Number of queries: 9
4 Correct 10 ms 1016 KB Number of queries: 9