Submission #242995

# Submission time Handle Problem Language Result Execution time Memory
242995 2020-06-30T07:13:00 Z nnnnnnnnnnnnnnnn Easter Eggs (info1cup17_eastereggs) C++14
0 / 100
6 ms 640 KB
#include<bits/stdc++.h>
#include "grader.h"
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
int n,cnt,mid;
vector<vi> graph;
vi node;
vi no,yes;
void dfs(int start,int pa)
{
	int i,j;
	if(cnt==mid)		return;
	node.push_back(start);
	if(no[start]==0)	++cnt;
	for(i=0;i<graph[start].size();++i)
	{
		j = graph[start][i];
		if(j!=pa)
		{
			dfs(j,start);
		}
	}
}
int findEgg(int n,vector<ii> edge)
{
	int i,j;
	graph.assign(n+1,vi());
	no.assign(n+1,0);
	yes.assign(n+1,0);
	for(i=1;i<n;++i)
	{
		graph[edge[i].first].push_back(edge[i].second);
		graph[edge[i].second].push_back(edge[i].first);
	}
	int curr = n;
	while(curr!=1)
	{
		node.clear();
		mid = curr/2;
		cnt = 0;
		dfs(1,-1);
		if(query(node)==false)
		{
			for(i=0;i<node.size();++i)
			{
				no[node[i]] = 1;
			}
			curr -= node.size();
		}
		else
		{
			for(i=0;i<node.size();++i)
			{
				if(no[node[i]]==0)
				{
					yes[node[i]] = 1;
				}
			}
			curr = mid;
		}
	}
	for(i=1;i<=n;++i)	
	{
		if(no[i]==0&&yes[i]==1)
		{
			return i;
		}
	}
}

Compilation message

eastereggs.cpp: In function 'void dfs(int, int)':
eastereggs.cpp:17:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(i=0;i<graph[start].size();++i)
          ~^~~~~~~~~~~~~~~~~~~~
eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:46:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(i=0;i<node.size();++i)
            ~^~~~~~~~~~~~
eastereggs.cpp:54:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(i=0;i<node.size();++i)
            ~^~~~~~~~~~~~
eastereggs.cpp:28:8: warning: unused variable 'j' [-Wunused-variable]
  int i,j;
        ^
eastereggs.cpp:71:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -