Submission #339238

# Submission time Handle Problem Language Result Execution time Memory
339238 2020-12-24T23:55:41 Z ogibogi2004 Easter Eggs (info1cup17_eastereggs) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;
const int MAXN=520;
int st[MAXN];
vector<int>g[MAXN];
bool no[MAXN];
void dfs(int u,int par)
{
	st[u]=1;
	for(auto v:g[u])
	{
		if(v==par)continue;
		if(no[v])continue;
		dfs(v,u);
		st[u]+=st[v];
	}
}
pair<int,int>best;
void find_best_in(int u,int par,int n1)
{
	if(st[u]>=n1)
	{
		best=min(best,{st[u]-n1,u});
	}
	else return;
	for(auto v:g[u])
	{
		if(v==par)continue;
		find_best_in(v,u,n1);
	}
}
vector<int>v;
bool flag;
void make_subtree(int u,int par,int t)
{
	if(u==t)flag=1;
	if(flag)v.push_back(u);
	for(auto v:g[u])
	{
		if(v==par)continue;
		make_subtree(v,u,t);
	}
	if(u==t)flag=0;
}
bool find(vector<int>xd1,int xd2)
{
	for(auto xd:xd1)if(xd==xd2)return 1;
	return 0;
}
int findEgg (int N, vector < pair < int, int > > bridges)
{
	for(auto xd:bridges)
	{
		g[xd.first].push_back(xd.second);
		g[xd.second].push_back(xd.first);
	}
	for(;;)
	{
		int root=0,cnt=0;
		for(int i=1;i<=N;i++)
		{
			if(no[i]==0)
			{
				root=i;cnt++;
			}
		}
		if(cnt==1)return root;
		dfs(root,0);
		best={N+1,N+1};
		find_best_in(root,0,st[root]/2);
		v.clear();
		flag=0;
		make_subtree(root,0,best.first);
		if(query(v))
		{
			for(int i=1;i<=N;i++)
			{
				if(findd(v,i)==v.end())
				{
					no[i]=1;
				}
			}
		}
		else
		{
			for(int i=0;i<v.size();i++)no[v[i]]=1;
		}
	}
    return N;
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:80:8: error: 'findd' was not declared in this scope; did you mean 'find'?
   80 |     if(findd(v,i)==v.end())
      |        ^~~~~
      |        find
eastereggs.cpp:88:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   88 |    for(int i=0;i<v.size();i++)no[v[i]]=1;
      |                ~^~~~~~~~~