제출 #242997

#제출 시각아이디문제언어결과실행 시간메모리
242997Exile_2k4Easter Eggs (info1cup17_eastereggs)C++17
컴파일 에러
0 ms0 KiB
#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); 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; }

컴파일 시 표준 에러 (stderr) 메시지

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:31:11: error: too few arguments to function 'void dfs(int, int, int)'
    dfs(i,i);
           ^
eastereggs.cpp:14:6: note: declared here
 void dfs(int p,int u, int need){
      ^~~
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:28:7: warning: unused variable 'mid' [-Wunused-variable]
   int mid = cnt/2;
       ^~~
eastereggs.cpp:44:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^