Submission #243000

# Submission time Handle Problem Language Result Execution time Memory
243000 2020-06-30T07:16:52 Z Exile_2k4 Easter Eggs (info1cup17_eastereggs) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;

const int sz = 600;

#define pii pair<int,int>

vector<int> g[sz], call;

bool exist[sz];

void dfs(int p,int u, int need){
	if(exist[u] && call.size()<need) call.push_back(u);
	for(auto v:g[u]) if(v!=p) dfs(u,v);
}

int findEgg(int N, vector<pii> bridges){
	for(int i=0;i<N-1;++i){
		g[bridges[i].first].push_back(bridges[i].second);
		g[bridges[i].second].push_back(bridges[i].first);
	}
	memset(exist,1,sizeof(exist));
	
	int cnt = N;
	while(cnt!=1){
		int mid = cnt/2;
		call.clear();
		for(int i=1;i<=N;++i) if(exist[i]){
			dfs(i,i,mid);
			break;
		}
		if(query(call)){
			set<int> focus(call);
			for(int i=1;i<=N;++i) exist[i] = focus.count(i);
			cnt = focus.size();
		}else{
			for(auto v:call) exist[v] = 0;
			cnt -= call.size();
		}
	}
	for(int i=1;i<=N;++i) if(exist[i]) return i;
}

Compilation message

eastereggs.cpp: In function 'void dfs(int, int, int)':
eastereggs.cpp:15:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if(exist[u] && call.size()<need) call.push_back(u);
                 ~~~~~~~~~~~^~~~~
eastereggs.cpp:16:35: error: too few arguments to function 'void dfs(int, int, int)'
  for(auto v:g[u]) if(v!=p) dfs(u,v);
                                   ^
eastereggs.cpp:14:6: note: declared here
 void dfs(int p,int u, int need){
      ^~~
eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:35:23: error: no matching function for call to 'std::set<int>::set(std::vector<int>&)'
    set<int> focus(call);
                       ^
In file included from /usr/include/c++/7/set:61:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:87,
                 from eastereggs.cpp:1:
/usr/include/c++/7/bits/stl_set.h:261:2: note: candidate: template<class _InputIterator> std::set<_Key, _Compare, _Alloc>::set(_InputIterator, _InputIterator, const allocator_type&)
  set(_InputIterator __first, _InputIterator __last,
  ^~~
/usr/include/c++/7/bits/stl_set.h:261:2: note:   template argument deduction/substitution failed:
eastereggs.cpp:35:23: note:   candidate expects 3 arguments, 1 provided
    set<int> focus(call);
                       ^
In file included from /usr/include/c++/7/set:61:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:87,
                 from eastereggs.cpp:1:
/usr/include/c++/7/bits/stl_set.h:255:7: note: candidate: std::set<_Key, _Compare, _Alloc>::set(std::initializer_list<_Tp>, const allocator_type&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; std::set<_Key, _Compare, _Alloc>::allocator_type = std::allocator<int>]
       set(initializer_list<value_type> __l, const allocator_type& __a)
       ^~~
/usr/include/c++/7/bits/stl_set.h:255:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/7/bits/stl_set.h:249:7: note: candidate: std::set<_Key, _Compare, _Alloc>::set(std::set<_Key, _Compare, _Alloc>&&, const allocator_type&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; std::set<_Key, _Compare, _Alloc>::allocator_type = std::allocator<int>]
       set(set&& __x, const allocator_type& __a)
       ^~~
/usr/include/c++/7/bits/stl_set.h:249:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/7/bits/stl_set.h:245:7: note: candidate: std::set<_Key, _Compare, _Alloc>::set(const std::set<_Key, _Compare, _Alloc>&, const allocator_type&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; std::set<_Key, _Compare, _Alloc>::allocator_type = std::allocator<int>]
       set(const set& __x, const allocator_type& __a)
       ^~~
/usr/include/c++/7/bits/stl_set.h:245:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/7/bits/stl_set.h:241:7: note: candidate: std::set<_Key, _Compare, _Alloc>::set(const allocator_type&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; std::set<_Key, _Compare, _Alloc>::allocator_type = std::allocator<int>]
       set(const allocator_type& __a)
       ^~~
/usr/include/c++/7/bits/stl_set.h:241:7: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const allocator_type& {aka const std::allocator<int>&}'
/usr/include/c++/7/bits/stl_set.h:233:7: note: candidate: std::set<_Key, _Compare, _Alloc>::set(std::initializer_list<_Tp>, const _Compare&, const allocator_type&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; std::set<_Key, _Compare, _Alloc>::allocator_type = std::allocator<int>]
       set(initializer_list<value_type> __l,
       ^~~
/usr/include/c++/7/bits/stl_set.h:233:7: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::initializer_list<int>'
/usr/include/c++/7/bits/stl_set.h:221:7: note: candidate: std::set<_Key, _Compare, _Alloc>::set(std::set<_Key, _Compare, _Alloc>&&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>]
       set(set&&) = default;
       ^~~
/usr/include/c++/7/bits/stl_set.h:221:7: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::set<int>&&'
/usr/include/c++/7/bits/stl_set.h:213:7: note: candidate: std::set<_Key, _Compare, _Alloc>::set(const std::set<_Key, _Compare, _Alloc>&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>]
       set(const set&) = default;
       ^~~
/usr/include/c++/7/bits/stl_set.h:213:7: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const std::set<int>&'
/usr/include/c++/7/bits/stl_set.h:198:2: note: candidate: template<class _InputIterator> std::set<_Key, _Compare, _Alloc>::set(_InputIterator, _InputIterator, const _Compare&, const allocator_type&)
  set(_InputIterator __first, _InputIterator __last,
  ^~~
/usr/include/c++/7/bits/stl_set.h:198:2: note:   template argument deduction/substitution failed:
eastereggs.cpp:35:23: note:   candidate expects 4 arguments, 1 provided
    set<int> focus(call);
                       ^
In file included from /usr/include/c++/7/set:61:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:87,
                 from eastereggs.cpp:1:
/usr/include/c++/7/bits/stl_set.h:181:2: note: candidate: template<class _InputIterator> std::set<_Key, _Compare, _Alloc>::set(_InputIterator, _InputIterator)
  set(_InputIterator __first, _InputIterator __last)
  ^~~
/usr/include/c++/7/bits/stl_set.h:181:2: note:   template argument deduction/substitution failed:
eastereggs.cpp:35:23: note:   candidate expects 2 arguments, 1 provided
    set<int> focus(call);
                       ^
In file included from /usr/include/c++/7/set:61:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:87,
                 from eastereggs.cpp:1:
/usr/include/c++/7/bits/stl_set.h:166:7: note: candidate: std::set<_Key, _Compare, _Alloc>::set(const _Compare&, const allocator_type&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; std::set<_Key, _Compare, _Alloc>::allocator_type = std::allocator<int>]
       set(const _Compare& __comp,
       ^~~
/usr/include/c++/7/bits/stl_set.h:166:7: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const std::less<int>&'
/usr/include/c++/7/bits/stl_set.h:157:7: note: candidate: std::set<_Key, _Compare, _Alloc>::set() [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>]
       set() = default;
       ^~~
/usr/include/c++/7/bits/stl_set.h:157:7: note:   candidate expects 0 arguments, 1 provided
eastereggs.cpp:44:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^