제출 #808669

#제출 시각아이디문제언어결과실행 시간메모리
808669ono_de206Unscrambling a Messy Bug (IOI16_messy)C++14
컴파일 에러
0 ms0 KiB
#include "messy.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; vector<int> ans; string str; void build(int l, int r) { if(l == r) { str[l] = '1'; add_element(str); str[l] = '0'; return; } int m = (l + r) >> 1; for(int i = l; i <= m; i++) { str[i] = '1'; add_element(str); str[i] = '0'; } for(int i = l; i <= m; i++) { str[i] = '1'; } build(m + 1, r); for(int i = l; i <= m; i++) { str[i] = '0'; } build(l, m); } void find(int l, int r, int vector<int> a) { if(l == r) { ans[l] = a[0]; } vector<int> L, R; for(int i = l; i <= r; i++) { int x = a[i]; str[x] = '1'; if(check_element(str)) L.pb(x); else R.pb(x); } for(int x : L) { str[x] = '1'; } find(m + 1, r, R); for(int x : L) { str[x] = '0'; } find(l, m, L); } vector<int> restore_permutation(int n, int w, int r) { vector<int> a(n); iota(all(a), 0); ans.resize(n); str = string(n, '0'); build(0, n - 1); compile_set(); str = string(n, '0'); find(0, n - 1, a); return ans; }

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

messy.cpp:46:41: error: expected unqualified-id before 'a'
   46 | void find(int l, int r, int vector<int> a) {
      |                                         ^
messy.cpp:46:40: error: expected ')' before 'a'
   46 | void find(int l, int r, int vector<int> a) {
      |          ~                             ^~
      |                                        )
messy.cpp:46:41: error: expected initializer before 'a'
   46 | void find(int l, int r, int vector<int> a) {
      |                                         ^
In file included from /usr/include/c++/10/vector:60,
                 from messy.h:3,
                 from messy.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h: In instantiation of '_Iterator std::__find_if(_Iterator, _Iterator, _Predicate) [with _Iterator = int; _Predicate = __gnu_cxx::__ops::_Iter_equals_val<const std::vector<int> >]':
/usr/include/c++/10/bits/stl_algo.h:3902:28:   required from '_IIter std::find(_IIter, _IIter, const _Tp&) [with _IIter = int; _Tp = std::vector<int>]'
messy.cpp:74:18:   required from here
/usr/include/c++/10/bits/stl_algobase.h:1978:34: error: no matching function for call to '__iterator_category(int&)'
 1978 |          std::__iterator_category(__first));
      |          ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:65,
                 from /usr/include/c++/10/vector:60,
                 from messy.h:3,
                 from messy.cpp:1:
/usr/include/c++/10/bits/stl_iterator_base_types.h:238:5: note: candidate: 'template<class _Iter> constexpr typename std::iterator_traits< <template-parameter-1-1> >::iterator_category std::__iterator_category(const _Iter&)'
  238 |     __iterator_category(const _Iter&)
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_iterator_base_types.h:238:5: note:   template argument deduction/substitution failed:
/usr/include/c++/10/bits/stl_iterator_base_types.h: In substitution of 'template<class _Iter> constexpr typename std::iterator_traits< <template-parameter-1-1> >::iterator_category std::__iterator_category(const _Iter&) [with _Iter = int]':
/usr/include/c++/10/bits/stl_algobase.h:1978:34:   required from '_Iterator std::__find_if(_Iterator, _Iterator, _Predicate) [with _Iterator = int; _Predicate = __gnu_cxx::__ops::_Iter_equals_val<const std::vector<int> >]'
/usr/include/c++/10/bits/stl_algo.h:3902:28:   required from '_IIter std::find(_IIter, _IIter, const _Tp&) [with _IIter = int; _Tp = std::vector<int>]'
messy.cpp:74:18:   required from here
/usr/include/c++/10/bits/stl_iterator_base_types.h:238:5: error: no type named 'iterator_category' in 'struct std::iterator_traits<int>'