제출 #630924

#제출 시각아이디문제언어결과실행 시간메모리
630924garam1732수천개의 섬 (IOI22_islands)C++17
컴파일 에러
0 ms0 KiB
#include "islands.h" #include <iostream> #include <variant> #include <vector> #include <algorithm> #include <map> #define ff first #define ss second using namespace std; typedef pair<int, int> pi; map<pi, int> m; vector<pi> adj[100100]; vector<pi> v; vector<int> ans; bool visited[100100]; int x = -1; void dfs(int here) { visited[here] = true; //cout << here << endl; for(pi there : adj[here]) { if(visited[there.ff]) { v.push_back(there); x = there.ff; return; } v.push_back(there); dfs(there.ff); if(x != -1) return; v.pop_back(); } } vector<int> em; //vector<int> find_journey( std::variant<bool, std::vector<int>> find_journey( int N, int M, std::vector<int> U, std::vector<int> V) { for(int i = 0; i < M; i+=2) { if(m.find(pi(U[i], V[i])) == m.end()) { adj[U[i]].push_back(pi(V[i], i)); } //adj[V[i]].push_back(pi(U[i], i)); m.insert(pi(U[i], V[i])); } dfs(0); if(x == -1) return false; int i; for(i = 0; i < v.size(); i++) if(v[i].ff == x) break; if(i == (int)v.size()-1) i = -1; for(int j = 0; j <= i; j++) ans.push_back(v[j].ss); for(int j = i+1; j < v.size(); j++) ans.push_back(v[j].ss); for(int j = i+1; j < v.size(); j++) ans.push_back(v[j].ss^1); for(int j = (int)v.size()-1; j > i; j--) ans.push_back(v[j].ss); for(int j = (int)v.size()-1; j > i; j--) ans.push_back(v[j].ss^1); for(int j = i; j >= 0; j--) ans.push_back(v[j].ss); return ans; // std::vector<int> v, w; // for(int i = 0; i < M; i++) { // if(U[i] == 0) v.push_back(i); // else w.push_back(i); // } // // if(v.size() < 2 || w.size() < 1) { // return em; // //return false; // } // std::vector<int> ans; // ans.push_back(v[0]); // ans.push_back(w[0]); // ans.push_back(v[1]); // ans.push_back(v[0]); // ans.push_back(w[0]); // ans.push_back(v[1]); // return ans; }

컴파일 시 표준 에러 (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:47:32: error: no matching function for call to 'std::map<std::pair<int, int>, int>::insert(pi)'
   47 |         m.insert(pi(U[i], V[i]));
      |                                ^
In file included from /usr/include/c++/10/map:61,
                 from islands.cpp:7:
/usr/include/c++/10/bits/stl_map.h:629:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::insert_return_type std::map<_Key, _Tp, _Compare, _Alloc>::insert(std::map<_Key, _Tp, _Compare, _Alloc>::node_type&&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::insert_return_type = std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::_Select1st<std::pair<const std::pair<int, int>, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<const std::pair<int, int>, int> > >::insert_return_type; std::map<_Key, _Tp, _Compare, _Alloc>::node_type = std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::_Select1st<std::pair<const std::pair<int, int>, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<const std::pair<int, int>, int> > >::node_type]'
  629 |       insert(node_type&& __nh)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_map.h:629:26: note:   no known conversion for argument 1 from 'pi' {aka 'std::pair<int, int>'} to 'std::map<std::pair<int, int>, int>::node_type&&' {aka 'std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::_Select1st<std::pair<const std::pair<int, int>, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<const std::pair<int, int>, int> > >::node_type&&'}
  629 |       insert(node_type&& __nh)
      |              ~~~~~~~~~~~~^~~~
/usr/include/c++/10/bits/stl_map.h:634:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::iterator std::map<_Key, _Tp, _Compare, _Alloc>::insert(std::map<_Key, _Tp, _Compare, _Alloc>::const_iterator, std::map<_Key, _Tp, _Compare, _Alloc>::node_type&&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::_Select1st<std::pair<const std::pair<int, int>, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<const std::pair<int, int>, int> > >::iterator; std::map<_Key, _Tp, _Compare, _Alloc>::const_iterator = std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::_Select1st<std::pair<const std::pair<int, int>, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<const std::pair<int, int>, int> > >::const_iterator; std::map<_Key, _Tp, _Compare, _Alloc>::node_type = std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::_Select1st<std::pair<const std::pair<int, int>, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<const std::pair<int, int>, int> > >::node_type]'
  634 |       insert(const_iterator __hint, node_type&& __nh)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_map.h:634:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/10/bits/stl_map.h:803:7: note: candidate: 'std::pair<typename std::_Rb_tree<_Key, std::pair<const _Key, _Tp>, std::_Select1st<std::pair<const _Key, _Tp> >, _Compare, typename __gnu_cxx::__alloc_traits<_Allocator>::rebind<std::pair<const _Key, _Tp> >::other>::iterator, bool> std::map<_Key, _Tp, _Compare, _Alloc>::insert(const value_type&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; typename std::_Rb_tree<_Key, std::pair<const _Key, _Tp>, std::_Select1st<std::pair<const _Key, _Tp> >, _Compare, typename __gnu_cxx::__alloc_traits<_Allocator>::rebind<std::pair<const _Key, _Tp> >::other>::iterator = std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::_Select1st<std::pair<const std::pair<int, int>, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<const std::pair<int, int>, int> > >::iterator; std::map<_Key, _Tp, _Compare, _Alloc>::value_type = std::pair<const std::pair<int, int>, int>]'
  803 |       insert(const value_type& __x)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_map.h:803:32: note:   no known conversion for argument 1 from 'pi' {aka 'std::pair<int, int>'} to 'const value_type&' {aka 'const std::pair<const std::pair<int, int>, int>&'}
  803 |       insert(const value_type& __x)
      |              ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_map.h:810:7: note: candidate: 'std::pair<typename std::_Rb_tree<_Key, std::pair<const _Key, _Tp>, std::_Select1st<std::pair<const _Key, _Tp> >, _Compare, typename __gnu_cxx::__alloc_traits<_Allocator>::rebind<std::pair<const _Key, _Tp> >::other>::iterator, bool> std::map<_Key, _Tp, _Compare, _Alloc>::insert(std::map<_Key, _Tp, _Compare, _Alloc>::value_type&&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; typename std::_Rb_tree<_Key, std::pair<const _Key, _Tp>, std::_Select1st<std::pair<const _Key, _Tp> >, _Compare, typename __gnu_cxx::__alloc_traits<_Allocator>::rebind<std::pair<const _Key, _Tp> >::other>::iterator = std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::_Select1st<std::pair<const std::pair<int, int>, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<const std::pair<int, int>, int> > >::iterator; std::map<_Key, _Tp, _Compare, _Alloc>::value_type = std::pair<const std::pair<int, int>, int>]'
  810 |       insert(value_type&& __x)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_map.h:810:27: note:   no known conversion for argument 1 from 'pi' {aka 'std::pair<int, int>'} to 'std::map<std::pair<int, int>, int>::value_type&&' {aka 'std::pair<const std::pair<int, int>, int>&&'}
  810 |       insert(value_type&& __x)
      |              ~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_map.h:816:2: note: candidate: 'template<class _Pair> std::__enable_if_t<std::is_constructible<std::pair<const _Key, _Tp>, _Pair>::value, std::pair<typename std::_Rb_tree<_Key, std::pair<const _Key, _Tp>, std::_Select1st<std::pair<const _Key, _Tp> >, _Compare, typename __gnu_cxx::__alloc_traits<_Allocator>::rebind<std::pair<const _Key, _Tp> >::other>::iterator, bool> > std::map<_Key, _Tp, _Compare, _Alloc>::insert(_Pair&&) [with _Pair = _Pair; _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]'
  816 |  insert(_Pair&& __x)
      |  ^~~~~~
/usr/include/c++/10/bits/stl_map.h:816:2: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/10/variant:36,
                 from islands.h:1,
                 from islands.cpp:1:
/usr/include/c++/10/type_traits: In substitution of 'template<bool _Cond, class _Tp> using __enable_if_t = typename std::enable_if::type [with bool _Cond = false; _Tp = std::pair<std::_Rb_tree_iterator<std::pair<const std::pair<int, int>, int> >, bool>]':
/usr/include/c++/10/bits/stl_map.h:816:2:   required by substitution of 'template<class _Pair> std::__enable_if_t<std::is_constructible<std::pair<const std::pair<int, int>, int>, _Pair>::value, std::pair<std::_Rb_tree_iterator<std::pair<const std::pair<int, int>, int> >, bool> > std::map<std::pair<int, int>, int>::insert<_Pair>(_Pair&&) [with _Pair = std::pair<int, int>]'
islands.cpp:47:32:   required from here
/usr/include/c++/10/type_traits:2192:11: error: no type named 'type' in 'struct std::enable_if<false, std::pair<std::_Rb_tree_iterator<std::pair<const std::pair<int, int>, int> >, bool> >'
 2192 |     using __enable_if_t = typename enable_if<_Cond, _Tp>::type;
      |           ^~~~~~~~~~~~~
In file included from /usr/include/c++/10/map:61,
                 from islands.cpp:7:
/usr/include/c++/10/bits/stl_map.h:830:7: note: candidate: 'void std::map<_Key, _Tp, _Compare, _Alloc>::insert(std::initializer_list<std::pair<const _Key, _Tp> >) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]'
  830 |       insert(std::initializer_list<value_type> __list)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_map.h:830:48: note:   no known conversion for argument 1 from 'pi' {aka 'std::pair<int, int>'} to 'std::initializer_list<std::pair<const std::pair<int, int>, int> >'
  830 |       insert(std::initializer_list<value_type> __list)
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
/usr/include/c++/10/bits/stl_map.h:860:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::iterator std::map<_Key, _Tp, _Compare, _Alloc>::insert(std::map<_Key, _Tp, _Compare, _Alloc>::const_iterator, const value_type&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::_Select1st<std::pair<const std::pair<int, int>, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<const std::pair<int, int>, int> > >::iterator; std::map<_Key, _Tp, _Compare, _Alloc>::const_iterator = std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::_Select1st<std::pair<const std::pair<int, int>, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<const std::pair<int, int>, int> > >::const_iterator; std::map<_Key, _Tp, _Compare, _Alloc>::value_type = std::pair<const std::pair<int, int>, int>]'
  860 |       insert(const_iterator __position, const value_type& __x)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_map.h:860:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/10/bits/stl_map.h:870:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::iterator std::map<_Key, _Tp, _Compare, _Alloc>::insert(std::map<_Key, _Tp, _Compare, _Alloc>::const_iterator, std::map<_Key, _Tp, _Compare, _Alloc>::value_type&&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::_Select1st<std::pair<const std::pair<int, int>, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<const std::pair<int, int>, int> > >::iterator; std::map<_Key, _Tp, _Compare, _Alloc>::const_iterator = std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::_Select1st<std::pair<const std::pair<int, int>, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<const std::pair<int, int>, int> > >::const_iterator; std::map<_Key, _Tp, _Compare, _Alloc>::value_type = std::pair<const std::pair<int, int>, int>]'
  870 |       insert(const_iterator __position, value_type&& __x)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_map.h:870:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/10/bits/stl_map.h:875:2: note: candidate: 'template<class _Pair> std::__enable_if_t<std::is_constructible<std::pair<const _Key, _Tp>, _Pair>::value, typename std::_Rb_tree<_Key, std::pair<const _Key, _Tp>, std::_Select1st<std::pair<const _Key, _Tp> >, _Compare, typename __gnu_cxx::__alloc_traits<_Allocator>::rebind<std::pair<const _Key, _Tp> >::other>::iterator> std::map<_Key, _Tp, _Compare, _Alloc>::insert(std::map<_Key, _Tp, _Compare, _Alloc>::const_iterator, _Pair&&) [with _Pair = _Pair; _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]'
  875 |  insert(const_iterator __position, _Pair&& __x)
      |  ^~~~~~
/usr/include/c++/10/bits/stl_map.h:875:2: note:   template argument deduction/substitution failed:
islands.cpp:47:32: note:   candidate expects 2 arguments, 1 provided
   47 |         m.insert(pi(U[i], V[i]));
      |                                ^
In file included from /usr/include/c++/10/map:61,
                 from islands.cpp:7:
/usr/include/c++/10/bits/stl_map.h:893:2: note: candidate: 'template<class _InputIterator> void std::map<_Key, _Tp, _Compare, _Alloc>::insert(_InputIterator, _InputIterator) [with _InputIterator = _InputIterator; _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]'
  893 |  insert(_InputIterator __first, _InputIterator __last)
      |  ^~~~~~
/usr/include/c++/10/bits/stl_map.h:893:2: note:   template argument deduction/substitution failed:
islands.cpp:47:32: note:   candidate expects 2 arguments, 1 provided
   47 |         m.insert(pi(U[i], V[i]));
      |                                ^
islands.cpp:55:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |     for(i = 0; i < v.size(); i++) if(v[i].ff == x) break;
      |                ~~^~~~~~~~~~
islands.cpp:59:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |     for(int j = i+1; j < v.size(); j++) ans.push_back(v[j].ss);
      |                      ~~^~~~~~~~~~
islands.cpp:60:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |     for(int j = i+1; j < v.size(); j++) ans.push_back(v[j].ss^1);
      |                      ~~^~~~~~~~~~