답안 #342587

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
342587 2021-01-02T12:00:00 Z ogibogi2004 Easter Eggs (info1cup17_eastereggs) C++14
100 / 100
25 ms 492 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;
const int MAXN=600;
vector<int>g[MAXN];
vector<int>order;
void dfs(int u,int p)
{
	order.push_back(u);
	for(auto v:g[u])
	{
		if(v==p)continue;
		dfs(v,u);
	}
}
int findEgg (int N, vector < pair < int, int > > bridges)
{
	for(int i=1;i<=N;i++)g[i].clear();
	order.clear();
	for(int i=0;i<bridges.size();++i)
	{
		g[bridges[i].first].push_back(bridges[i].second);
		g[bridges[i].second].push_back(bridges[i].first);
	}
	dfs(1,0);
	int low=0,high=N-2,mid,ans=N-1;
	while(low<=high)
	{
		mid=(low+high)/2;
		vector<int>q;
		for(int i=0;i<=mid;++i)q.push_back(order[i]);
		if(query(q))
		{
			ans=mid;
			high=mid-1;
		}
		else low=mid+1;
	}
	return order[ans];
    if (query ({1})) return 1;
    return N;
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:21:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |  for(int i=0;i<bridges.size();++i)
      |              ~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Number of queries: 4
2 Correct 1 ms 364 KB Number of queries: 4
3 Correct 1 ms 364 KB Number of queries: 4
4 Correct 1 ms 364 KB Number of queries: 4
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 364 KB Number of queries: 8
2 Correct 15 ms 364 KB Number of queries: 9
3 Correct 22 ms 364 KB Number of queries: 9
4 Correct 18 ms 364 KB Number of queries: 9
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 492 KB Number of queries: 9
2 Correct 18 ms 492 KB Number of queries: 9
3 Correct 19 ms 364 KB Number of queries: 9
4 Correct 25 ms 364 KB Number of queries: 9