Submission #380900

#TimeUsernameProblemLanguageResultExecution timeMemory
380900ritul_kr_singhCombo (IOI18_combo)C++17
Compilation error
0 ms0 KiB
#include "combo.h" #include "bits/stdc++.h" using namespace std; string guess_sequence(int n){ string s; if(press("AB")) s = press("A") ? "A" : "B"; else s = press("X") ? "X" : "Y"; string all, orig = "ABXY"; for(char c : orig) if(c!=s[0]) all.push_back(c); for(int i=1; i+1<n; ++i){ string t; for(char c : all) t.push_back(s + all[2] + c); t.push_back(s + all[1]); s += all[press(t)-i]; } string t; if(press(s+all[0]+s+all[1])==n) s += (press(s+all[0])==n) ? all[0] : all[1]; else s += all[2]; return s; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:17:44: error: cannot convert 'std::__cxx11::basic_string<char>' to 'char'
   17 |   for(char c : all) t.push_back(s + all[2] + c);
      |                                 ~~~~~~~~~~~^~~
      |                                            |
      |                                            std::__cxx11::basic_string<char>
In file included from /usr/include/c++/10/string:55,
                 from combo.h:3,
                 from combo.cpp:1:
/usr/include/c++/10/bits/basic_string.h:1320:24: note:   initializing argument 1 of 'void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::push_back(_CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1320 |       push_back(_CharT __c)
      |                 ~~~~~~~^~~
combo.cpp:18:17: error: cannot convert 'std::__cxx11::basic_string<char>' to 'char'
   18 |   t.push_back(s + all[1]);
In file included from /usr/include/c++/10/string:55,
                 from combo.h:3,
                 from combo.cpp:1:
/usr/include/c++/10/bits/basic_string.h:1320:24: note:   initializing argument 1 of 'void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::push_back(_CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1320 |       push_back(_CharT __c)
      |                 ~~~~~~~^~~