Submission #342586

# Submission time Handle Problem Language Result Execution time Memory
342586 2021-01-02T11:59:10 Z ogibogi2004 Easter Eggs (info1cup17_eastereggs) C++14
87 / 100
25 ms 552 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-1,mid,ans;
	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)
      |              ~^~~~~~~~~~~~~~~
eastereggs.cpp:40:18: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   40 |  return order[ans];
      |                  ^
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 364 KB Number of queries: 5
2 Partially correct 1 ms 512 KB Number of queries: 5
3 Partially correct 1 ms 364 KB Number of queries: 5
4 Partially correct 1 ms 364 KB Number of queries: 5
# Verdict Execution time Memory Grader output
1 Correct 6 ms 364 KB Number of queries: 9
2 Correct 14 ms 384 KB Number of queries: 9
3 Correct 21 ms 364 KB Number of queries: 9
4 Correct 19 ms 364 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Partially correct 21 ms 364 KB Number of queries: 10
2 Correct 22 ms 364 KB Number of queries: 9
3 Partially correct 20 ms 364 KB Number of queries: 10
4 Partially correct 25 ms 552 KB Number of queries: 10