Submission #1148870

#TimeUsernameProblemLanguageResultExecution timeMemory
1148870andrejikus콤보 (IOI18_combo)C++20
Compilation error
0 ms0 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; void DBG() { cerr << "]" << endl; } template<class H, class... T> void DBG(H h, T... t) { cerr << to_string(h); if(sizeof...(t)) cerr << ", "; DBG(t...); } #define dbg(...) cerr << "[" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__) const int N = 2e5 + 3; string ELEM[4] = {"A", "B", "X", "Y"}; string guess_sequence(int n) { string s = ""; string p = ELEM[0] + ELEM[1]; if (press(p) > 0) { string c = ELEM[0]; if (press(c)) s += ELEM[0]; else s += ELEM[1]; } else { string c = ELEM[2]; if (press(c)) s += ELEM[2]; else s += ELEM[3]; } /// 3 qry for (int i = 2; i <= n; i++) { vector<char> vec; for (int d = 0; d < 4; d++) if (s[0] != char(ELEM[d])) vec.push_back(ELEM[d]); string p = s + vec[0] + s + vec[1]; if (press(p) == i) { string c = s + vec[0]; if (press(c) == i) s += vec[0]; else s += vec[1]; } else { s += vec[2]; } } return s; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:34:25: error: invalid cast from type 'std::string' {aka 'std::__cxx11::basic_string<char>'} to type 'char'
   34 |             if (s[0] != char(ELEM[d]))
      |                         ^~~~~~~~~~~~~
combo.cpp:35:30: error: no matching function for call to 'std::vector<char>::push_back(std::string&)'
   35 |                 vec.push_back(ELEM[d]);
      |                 ~~~~~~~~~~~~~^~~~~~~~~
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 = char; _Alloc = std::allocator<char>; std::vector<_Tp, _Alloc>::value_type = 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::string' {aka 'std::__cxx11::basic_string<char>'} to 'const value_type&' {aka 'const 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 = char; _Alloc = std::allocator<char>; std::vector<_Tp, _Alloc>::value_type = 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::string' {aka 'std::__cxx11::basic_string<char>'} to 'std::vector<char>::value_type&&' {aka 'char&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~