Submission #361987

# Submission time Handle Problem Language Result Execution time Memory
361987 2021-02-01T14:05:00 Z keta_tsimakuridze Easter Eggs (info1cup17_eastereggs) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "grader.h"
#define f first
#define s second
using namespace std;
const int N=505;
int sz[N],par[N],fix[N],n,Egg[N],cnt,ind[N],timer,ans;
vector<int>v,V[N];
bool query(vector<int> v){
	for(int i=0;i<v.size();i++){
		if(Egg[v[i]]) return 1;
	}
	return 0;
}
int dfs(int u,int p){
	timer++;
	ind[timer]=u;  
	for(int i=0;i<V[u].size();i++){
		if(V[u][i]==p) continue;
		dfs(V[u][i],u);
	}
}
int findEgg (int n1, vector < pair < int, int > > b)
{
	n=n1;
  for(int i=1;i<=n;i++)V[i].clear();
   for(int i=0;i<b.size();i++){
   	V[b[i].f].push_back(b[i].s);
   	V[b[i].s].push_back(b[i].f);
   }
   dfs(1,0);
   int l=1,r=n;	
   while(l<=r){
   	int mid=(l+r)/2;
   	v.clear();
   	for(int i=1;i<=mid;i++){
   		v.push_back(ind[i]);
	}
	if(query(v)){
		ans=ind[mid];
		r=mid-1;
	}
	else l=mid+1;
   }
   return ans;
}
int main(){
	int e;
	cin>>n>>e;
	std::vector<pair<int,int> > b;
	Egg[e]=1;
	for(int k=2;k<=n;k++){
		int u,v;
		cin>>u>>v;
		b.push_back({u,v});
	}
	cout<<findEgg(n,b)<<endl;
}

Compilation message

eastereggs.cpp:9:6: error: ambiguating new declaration of 'bool query(std::vector<int>)'
    9 | bool query(vector<int> v){
      |      ^~~~~
In file included from eastereggs.cpp:2:
grader.h:6:5: note: old declaration 'int query(std::vector<int>)'
    6 | int query(vector < int > islands);
      |     ^~~~~
eastereggs.cpp: In function 'bool query(std::vector<int>)':
eastereggs.cpp:10:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |  for(int i=0;i<v.size();i++){
      |              ~^~~~~~~~~
eastereggs.cpp: In function 'int dfs(int, int)':
eastereggs.cpp:18:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |  for(int i=0;i<V[u].size();i++){
      |              ~^~~~~~~~~~~~
eastereggs.cpp:22:1: warning: no return statement in function returning non-void [-Wreturn-type]
   22 | }
      | ^
eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:27:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |    for(int i=0;i<b.size();i++){
      |                ~^~~~~~~~~