Submission #786308

#TimeUsernameProblemLanguageResultExecution timeMemory
786308ono_de206수천개의 섬 (IOI22_islands)C++17
Compilation error
0 ms0 KiB
#include "islands.h" #include<bits/stdc++.h> using namespace std; #define in insert #define all(x) x.begin(),x.end() #define pb push_back #define eb emplace_back #define ff first #define ss second //#define int long long typedef long long ll; typedef vector<int> vi; typedef set<int> si; typedef multiset<int> msi; typedef pair<int, int> pii; typedef vector<pii> vpii; const int mxn = 1e5 + 10; vector<pair<int, int>> g[mxn]; bool tp, found; vector<int> ans; int vis[mxn], p[mxn]; void dfs(int to, int fr) { p[to] = fr; vis[to] = 1; vector<int> lol; for(auto it : g[to]) { int x = it.ff, id = it.ss; if(id == fr || vis[x]) continue; lol.pb(id); } if(lol.size() >= 2 && !tp) { vector<int> tmp = ans; tmp.pb(lol[0]); tmp.pb(lol[0] ^ 1); tmp.pb(lol[1]); tmp.pb(lol[1] ^ 1); tmp.pb(lol[0] ^ 1); tmp.pb(lol[0]); tmp.pb(lol[1] ^ 1); tmp.pb(lol[1]); tmp.in(tmp.end(), ans.rbegin(), ans.end()); swap(tmp, ans); found = 1; return; } if(found) return; for(auto it : g[to]) { int x = it.ff, id = it.ss; if(vis[x] == 2) continue; if(id / 2 == fr / 2) continue; ans.pb(id); if(vis[x] == 1) { found = 1; vector<int> cyc; while(ans.size() && ans.back() != p[x]) { cyc.pb(ans.back()); ans.pop_back(); } reverse(all(cyc)); vector<int> tmp = ans; if(tp) { for(int x : cyc) tmp.pb(x); for(int x : cyc) tmp.pb(x ^ 1); reverse(all(cyc)); for(int x : cyc) tmp.pb(x); for(int x : cyc) tmp.pb(x ^ 1); } else { for(int x : cyc) tmp.pb(x); reverse(all(cyc)); for(int x : cyc) tmp.pb(x ^ 1); for(int x : cyc) tmp.pb(x); reverse(all(cyc)); for(int x : cyc) tmp.pb(x ^ 1); } tmp.in(tmp.end(), ans.rbegin(), ans.rend()); swap(tmp, ans); } else { dfs(x, id); } if(found) return; ans.pop_back(); } vis[to] = 2; } variant<bool, vector<int>> find_journey(int n, int m, vector<int> U, vector<int> V) { if(n == 2) { vector<int> a0, a1; for(int i = 0; i < m; i++) { if(U[i] == 0) a0.pb(i); else a1.pb(i); } if(a0.size() >= 2 && a1.size() >= 1) return vector<int>{a0[0], a1[0], a0[1], a0[0], a1[0], a0[1]}; else return false; } if(U[0] == U[1]) tp = 1; for(int i = 0; i < m; i++) { g[U[i]].eb(V[i], i); } dfs(0, -10000); if(found) return ans; return false; }

Compilation message (stderr)

islands.cpp: In function 'void dfs(int, int)':
islands.cpp:46:44: error: no matching function for call to 'std::vector<int>::insert(std::vector<int>::iterator, std::vector<int>::reverse_iterator, std::vector<int>::iterator)'
   46 |   tmp.in(tmp.end(), ans.rbegin(), ans.end());
      |                                            ^
In file included from /usr/include/c++/10/vector:72,
                 from islands.h:2,
                 from islands.cpp:1:
/usr/include/c++/10/bits/vector.tcc:130:5: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::iterator = std::vector<int>::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<int>::const_iterator; std::vector<_Tp, _Alloc>::value_type = int]'
  130 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/vector.tcc:130:5: note:   candidate expects 2 arguments, 3 provided
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:1293:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::iterator = std::vector<int>::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<int>::const_iterator; std::vector<_Tp, _Alloc>::value_type = int]'
 1293 |       insert(const_iterator __position, value_type&& __x)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:1293:7: note:   candidate expects 2 arguments, 3 provided
/usr/include/c++/10/bits/stl_vector.h:1310:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::iterator = std::vector<int>::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<int>::const_iterator]'
 1310 |       insert(const_iterator __position, initializer_list<value_type> __l)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:1310:7: note:   candidate expects 2 arguments, 3 provided
/usr/include/c++/10/bits/stl_vector.h:1335:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, std::vector<_Tp, _Alloc>::size_type, const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::iterator = std::vector<int>::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<int>::const_iterator; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type = int]'
 1335 |       insert(const_iterator __position, size_type __n, const value_type& __x)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:1335:51: note:   no known conversion for argument 2 from 'std::vector<int>::reverse_iterator' {aka 'std::reverse_iterator<__gnu_cxx::__normal_iterator<int*, std::vector<int> > >'} to 'std::vector<int>::size_type' {aka 'long unsigned int'}
 1335 |       insert(const_iterator __position, size_type __n, const value_type& __x)
      |                                         ~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1379:2: note: candidate: 'template<class _InputIterator, class> std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, _InputIterator, _InputIterator) [with _InputIterator = _InputIterator; <template-parameter-2-2> = <template-parameter-1-2>; _Tp = int; _Alloc = std::allocator<int>]'
 1379 |  insert(const_iterator __position, _InputIterator __first,
      |  ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:1379:2: note:   template argument deduction/substitution failed:
islands.cpp:46:44: note:   deduced conflicting types for parameter '_InputIterator' ('std::reverse_iterator<__gnu_cxx::__normal_iterator<int*, std::vector<int> > >' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >')
   46 |   tmp.in(tmp.end(), ans.rbegin(), ans.end());
      |                                            ^