Submission #787183

#TimeUsernameProblemLanguageResultExecution timeMemory
787183resolve100Combo (IOI18_combo)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #include "combo.h" #define ll long long #define ull unsigned ll #define pb push_back #define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0) #define read_file freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); using namespace std; string chars[] = {"A", "B", "X", "Y"}; string guess_sequence(int N){ string out; int no; for (int i = 0; i < 3; i++){ int num = press(chars[i]); if (num){ out.append(chars[i]); no = i; break; } } if (out.size() == 0) out.pb(chars[3]); for (int i = 1; i < N; i++){ if (no == 3){ for (int j = 2; j > 1; j--){ int num = press(out+chars[j]); if (num == i+1){ out.append(chars[j]); break; } } if (out.size() == i) out.append(arr[0]); } else{ for (int j = 0; j < 3; j++){ if (i == j) continue; int num = press(out+chars[i]); if (num == i+1){ out.append(chars[i]); break; } } if (out.size() == i) out.append(arr[3]); } } return out; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:26:37: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'char'
   26 |  if (out.size() == 0) out.pb(chars[3]);
      |                              ~~~~~~~^
      |                                     |
      |                                     std::string {aka std::__cxx11::basic_string<char>}
In file included from /usr/include/c++/10/string:55,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 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:37:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   37 |    if (out.size() == i) out.append(arr[0]);
      |        ~~~~~~~~~~~^~~~
combo.cpp:37:36: error: 'arr' was not declared in this scope
   37 |    if (out.size() == i) out.append(arr[0]);
      |                                    ^~~
combo.cpp:48:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   48 |    if (out.size() == i) out.append(arr[3]);
      |        ~~~~~~~~~~~^~~~
combo.cpp:48:36: error: 'arr' was not declared in this scope
   48 |    if (out.size() == i) out.append(arr[3]);
      |                                    ^~~