제출 #1064251

#제출 시각아이디문제언어결과실행 시간메모리
1064251MarwenElarbi수천개의 섬 (IOI22_islands)C++17
컴파일 에러
0 ms0 KiB
#include "islands.h" #include <bits/stdc++.h> using namespace std; #define pb push_back #define ll long long #define fi first #define se second vector<int> adj[405]; std::variant<bool, std::vector<int>> find_journey( int N, int M, std::vector<int> U, std::vector<int> V) { vector<int> a; vector<int> b; for (int i = 0; i < M; ++i) { (U[i]==0 ? a : b).pb(i); adj[U[i]].pb({V[i],i}); } if(a.size()>=2&&b.size()>=1){ if(N==2) return vector<int> ({a[0],b[0],a[1],a[0],b[0],a[1]}); else{ int x=adj[0][0].fi; int y=adj[0][1].fi; int c,d; for(auto u:adj[x]) if(u.fi==0) c=u.se; for(auto u:adj[y]) if(u.fi==0) d=u.se; return vector<int> ({adj[0][0].se,c,adj[0][1].se,d,c,adj[0][0].se,d,adj[0][1].se}); } } return false; }

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

islands.cpp: In function 'std::variant<bool, std::vector<int, std::allocator<int> > > find_journey(int, int, std::vector<int>, std::vector<int>)':
islands.cpp:16:26: error: no matching function for call to 'std::vector<int>::push_back(<brace-enclosed initializer list>)'
   16 |     adj[U[i]].pb({V[i],i});
      |                          ^
In file included from /usr/include/c++/10/vector:67,
                 from islands.h:2,
                 from islands.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const int&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<int>::value_type&&' {aka 'int&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
islands.cpp:6:12: error: request for member 'first' in 'adj[0].std::vector<int>::operator[](0)', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
    6 | #define fi first
      |            ^~~~~
islands.cpp:21:23: note: in expansion of macro 'fi'
   21 |       int x=adj[0][0].fi;
      |                       ^~
islands.cpp:6:12: error: request for member 'first' in 'adj[0].std::vector<int>::operator[](1)', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
    6 | #define fi first
      |            ^~~~~
islands.cpp:22:23: note: in expansion of macro 'fi'
   22 |       int y=adj[0][1].fi;
      |                       ^~
islands.cpp:6:12: error: request for member 'first' in 'u', which is of non-class type 'int'
    6 | #define fi first
      |            ^~~~~
islands.cpp:24:31: note: in expansion of macro 'fi'
   24 |       for(auto u:adj[x]) if(u.fi==0) c=u.se;
      |                               ^~
islands.cpp:7:12: error: request for member 'second' in 'u', which is of non-class type 'int'
    7 | #define se second
      |            ^~~~~~
islands.cpp:24:42: note: in expansion of macro 'se'
   24 |       for(auto u:adj[x]) if(u.fi==0) c=u.se;
      |                                          ^~
islands.cpp:6:12: error: request for member 'first' in 'u', which is of non-class type 'int'
    6 | #define fi first
      |            ^~~~~
islands.cpp:25:31: note: in expansion of macro 'fi'
   25 |       for(auto u:adj[y]) if(u.fi==0) d=u.se;
      |                               ^~
islands.cpp:7:12: error: request for member 'second' in 'u', which is of non-class type 'int'
    7 | #define se second
      |            ^~~~~~
islands.cpp:25:42: note: in expansion of macro 'se'
   25 |       for(auto u:adj[y]) if(u.fi==0) d=u.se;
      |                                          ^~
islands.cpp:7:12: error: request for member 'second' in 'adj[0].std::vector<int>::operator[](0)', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
    7 | #define se second
      |            ^~~~~~
islands.cpp:26:38: note: in expansion of macro 'se'
   26 |       return vector<int> ({adj[0][0].se,c,adj[0][1].se,d,c,adj[0][0].se,d,adj[0][1].se});
      |                                      ^~
islands.cpp:7:12: error: request for member 'second' in 'adj[0].std::vector<int>::operator[](1)', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
    7 | #define se second
      |            ^~~~~~
islands.cpp:26:53: note: in expansion of macro 'se'
   26 |       return vector<int> ({adj[0][0].se,c,adj[0][1].se,d,c,adj[0][0].se,d,adj[0][1].se});
      |                                                     ^~
islands.cpp:7:12: error: request for member 'second' in 'adj[0].std::vector<int>::operator[](0)', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
    7 | #define se second
      |            ^~~~~~
islands.cpp:26:70: note: in expansion of macro 'se'
   26 |       return vector<int> ({adj[0][0].se,c,adj[0][1].se,d,c,adj[0][0].se,d,adj[0][1].se});
      |                                                                      ^~
islands.cpp:7:12: error: request for member 'second' in 'adj[0].std::vector<int>::operator[](1)', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
    7 | #define se second
      |            ^~~~~~
islands.cpp:26:85: note: in expansion of macro 'se'
   26 |       return vector<int> ({adj[0][0].se,c,adj[0][1].se,d,c,adj[0][0].se,d,adj[0][1].se});
      |                                                                                     ^~
islands.cpp:26:88: error: no matching function for call to 'std::vector<int>::vector(<brace-enclosed initializer list>)'
   26 |       return vector<int> ({adj[0][0].se,c,adj[0][1].se,d,c,adj[0][0].se,d,adj[0][1].se});
      |                                                                                        ^
In file included from /usr/include/c++/10/vector:67,
                 from islands.h:2,
                 from islands.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:653:2: note: candidate: 'template<class _InputIterator, class> std::vector<_Tp, _Alloc>::vector(_InputIterator, _InputIterator, const allocator_type&) [with _InputIterator = _InputIterator; <template-parameter-2-2> = <template-parameter-1-2>; _Tp = int; _Alloc = std::allocator<int>]'
  653 |  vector(_InputIterator __first, _InputIterator __last,
      |  ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:653:2: note:   template argument deduction/substitution failed:
islands.cpp:26:88: note:   candidate expects 3 arguments, 1 provided
   26 |       return vector<int> ({adj[0][0].se,c,adj[0][1].se,d,c,adj[0][0].se,d,adj[0][1].se});
      |                                                                                        ^
In file included from /usr/include/c++/10/vector:67,
                 from islands.h:2,
                 from islands.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:625:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::initializer_list<_Tp>, const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>]'
  625 |       vector(initializer_list<value_type> __l,
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:625:43: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::initializer_list<int>'
  625 |       vector(initializer_list<value_type> __l,
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:607:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>]'
  607 |       vector(vector&& __rv, const allocator_type& __m)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:607:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/10/bits/stl_vector.h:589:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::false_type) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>; std::false_type = std::integral_constant<bool, false>]'
  589 |       vector(vector&& __rv, const allocator_type& __m, false_type)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:589:7: note:   candidate expects 3 arguments, 1 provided
/usr/include/c++/10/bits/stl_vector.h:585:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::true_type) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>; std::true_type = std::integral_constant<bool, true>]'
  585 |       vector(vector&& __rv, const allocator_type& __m, true_type) noexcept
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:585:7: note:   candidate expects 3 arguments, 1 provided
/usr/include/c++/10/bits/stl_vector.h:575:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&, const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>]'
  575 |       vector(const vector& __x, const allocator_type& __a)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:575:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/10/bits/stl_vector.h:572:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]'
  572 |       vector(vector&&) noexcept = default;
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:572:14: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<int>&&'
  572 |       vector(vector&&) noexcept = default;
      |              ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:553:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]'
  553 |       vector(const vector& __x)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:553:28: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::vector<int>&'
  553 |       vector(const vector& __x)
      |              ~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:522:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>::size_type, const value_type&, const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type = int; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>]'
  522 |       vector(size_type __n, const value_type& __value,
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:522:7: note:   candidate expects 3 arguments, 1 provided
/usr/include/c++/10/bits/stl_vector.h:510:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>::size_type, const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>]'
  510 |       vector(size_type __n, const allocator_type& __a = allocator_type())
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:510:24: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<int>::size_type' {aka 'long unsigned int'}
  510 |       vector(size_type __n, const allocator_type& __a = allocator_type())
      |              ~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:497:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>]'
  497 |       vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:497:36: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const allocator_type&' {aka 'const std::allocator<int>&'}
  497 |       vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT
      |              ~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:487:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector() [with _Tp = int; _Alloc = std::allocator<int>]'
  487 |       vector() = default;
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:487:7: note:   candidate expects 0 arguments, 1 provided