Submission #342585

# Submission time Handle Problem Language Result Execution time Memory
342585 2021-01-02T11:57:38 Z ogibogi2004 Easter Eggs (info1cup17_eastereggs) C++14
0 / 100
400 ms 131076 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=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:19: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]
   19 |  for(int i=0;i<bridges.size();i++)
      |              ~^~~~~~~~~~~~~~~
eastereggs.cpp:38:18: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   38 |  return order[ans];
      |                  ^
# Verdict Execution time Memory Grader output
1 Execution timed out 408 ms 131076 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 281 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 283 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -