답안 #1057170

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1057170 2024-08-13T14:41:26 Z Drifter24 Easter Eggs (info1cup17_eastereggs) C++14
87 / 100
11 ms 752 KB
#include <bits/stdc++.h>
using namespace std;

int query(vector < int > islands);
void dfs(int v, int p, vector<vector<int>>& adj, vector<int>& ans){
	ans.push_back(v);
	for(int u:adj[v]){
		if(u==p)continue;
		dfs(u, v, adj, ans);
	}
}

int findEgg(int N, vector < pair < int, int > > bridges){
	vector<int> ans;
	vector<vector<int>> adj(N+1, vector<int>());
	for(auto x:bridges){
		adj[x.first].push_back(x.second);
		adj[x.second].push_back(x.first);
	}
	dfs(1, 0, adj, ans);
	int l=-1,r=N;
	while(r-l>1){
		int m=(r+l)/2;
		vector<int> q;
		for(int i=0;i<=m;++i)q.push_back(ans[i]);
		if(query(q))r=m;
		else l=m;
	}
	return ans[r];
}
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 344 KB Number of queries: 5
2 Partially correct 0 ms 344 KB Number of queries: 5
3 Partially correct 0 ms 344 KB Number of queries: 5
4 Partially correct 1 ms 344 KB Number of queries: 5
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 344 KB Number of queries: 9
2 Correct 6 ms 344 KB Number of queries: 9
3 Correct 9 ms 344 KB Number of queries: 9
4 Correct 8 ms 344 KB Number of queries: 9
# 결과 실행 시간 메모리 Grader output
1 Partially correct 11 ms 600 KB Number of queries: 10
2 Correct 10 ms 752 KB Number of queries: 9
3 Partially correct 9 ms 344 KB Number of queries: 10
4 Partially correct 10 ms 600 KB Number of queries: 10