제출 #1191876

#제출 시각아이디문제언어결과실행 시간메모리
1191876p4r4d0_xCombo (IOI18_combo)C++20
컴파일 에러
0 ms0 KiB
#include "combo.h" #include<bits/stdc++.h> using namespace std; #define pb push_back #define ll long long string guess_sequence(int N) { vector<char> a = {'A', 'B', 'X', 'Y'}; string s = ""; for(int i = 0; i < 4; ++i){ s += a[i]; if(press(s) == 1){ break; } else s = ""; } vector<char> b; for(int i = 0; i < 4; ++i){ if(a[i] != s[0]){ b.pb(a[i]); } } vector<string> vs; sort(begin(b), end(b)); do{ string st = ""; for(int i = 0; i < 3; ++i){ st += b[i]; } vs.pb(b); } while(next_permutation(begin(b), end(b))); ll cnt = 1; while(cnt != N){ if(cnt + 3 <= N){ for(auto &x : vs){ if(press(s + x) == cnt + 3){ s += x; cnt += 3; break; } } } else{ for(int i = 0; i < 3; ++i){ if(press(s + b[i]) == cnt + 1){ s += a[i]; cnt++; break; } } } } return s; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:30:12: error: no matching function for call to 'std::vector<std::__cxx11::basic_string<char> >::push_back(std::vector<char>&)'
   30 |       vs.pb(b);
      |       ~~~~~^~~
In file included from /usr/include/c++/11/vector:67,
                 from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from combo.cpp:2:
/usr/include/c++/11/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::__cxx11::basic_string<char>; _Alloc = std::allocator<std::__cxx11::basic_string<char> >; std::vector<_Tp, _Alloc>::value_type = std::__cxx11::basic_string<char>]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from 'std::vector<char>' to 'const value_type&' {aka 'const std::__cxx11::basic_string<char>&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/11/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::__cxx11::basic_string<char>; _Alloc = std::allocator<std::__cxx11::basic_string<char> >; std::vector<_Tp, _Alloc>::value_type = std::__cxx11::basic_string<char>]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from 'std::vector<char>' to 'std::vector<std::__cxx11::basic_string<char> >::value_type&&' {aka 'std::__cxx11::basic_string<char>&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~