Submission #729802

#TimeUsernameProblemLanguageResultExecution timeMemory
7298022vasCombo (IOI18_combo)C++17
Compilation error
0 ms0 KiB
// Source: https://usaco.guide/general/io #include <bits/stdc++.h> using namespace std; string guess_sequence(int n) { // get first letter char first; char other[3]; if (press("AB")) { if (press("A")) { first = 'A'; other[0] = 'B'; other[1] = 'X'; other[2] = 'Y'; } else { first = 'B'; other[0] = 'A'; other[1] = 'X'; other[2] = 'Y'; } } else { if (press("X")) { first = 'X'; other[0] = 'B'; other[1] = 'A'; other[2] = 'Y'; } else { first = 'Y'; other[0] = 'A'; other[1] = 'X'; other[2] = 'B'; } } string s = "" + first; while (s.length() < n - 1) { string p = s + other[0] + other[1]; p += s + other[0] + other[2]; p += s + other[1] + other[2]; int v = press(p); if (v == 0 + s.length()) { s += other[2]; continue; } if (v == 1 + s.length()) { p = s + other[1] + other[1]; v = press(p); if (v == 0 + s.length()) { s += other[0] + other[0]; } else if (v == 1 + s.length()) { s += other[1] + other[0]; } else { assert(v == 2 + s.length()); s += other[1] + other[1]; } continue; } if (v == 2 + s.length()) { p = s + other[0] + other[1]; v = press(p); if (v == 0 + s.length()) { s += other[1] + other[2]; } else if (v == 1 + s.length()) { s += other[0] + other[2]; } else { assert(v == 2 + s.length()); s += other[0] + other[1]; } continue; } } if (s.length() == n) { return s; } if (press(s + other[0] + s + other[1]) == n) { if (press(s + other[0]) == n) { s += other[0]; } else { s += other[1]; } } else { s += other[2]; } return s; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:12:6: error: 'press' was not declared in this scope
   12 |  if (press("AB")) {
      |      ^~~~~
combo.cpp:40:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   40 |  while (s.length() < n - 1) {
      |         ~~~~~~~~~~~^~~~~~~
combo.cpp:44:11: error: 'press' was not declared in this scope
   44 |   int v = press(p);
      |           ^~~~~
combo.cpp:46:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |   if (v == 0 + s.length()) {
      |       ~~^~~~~~~~~~~~~~~~~
combo.cpp:51:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |   if (v == 1 + s.length()) {
      |       ~~^~~~~~~~~~~~~~~~~
combo.cpp:54:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |    if (v == 0 + s.length()) {
      |        ~~^~~~~~~~~~~~~~~~~
combo.cpp:56:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |    } else if (v == 1 + s.length()) {
      |               ~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from combo.cpp:3:
combo.cpp:59:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |     assert(v == 2 + s.length());
      |            ~~^~~~~~~~~~~~~~~~~
combo.cpp:65:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |   if (v == 2 + s.length()) {
      |       ~~^~~~~~~~~~~~~~~~~
combo.cpp:68:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |    if (v == 0 + s.length()) {
      |        ~~^~~~~~~~~~~~~~~~~
combo.cpp:70:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |    } else if (v == 1 + s.length()) {
      |               ~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from combo.cpp:3:
combo.cpp:73:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   73 |     assert(v == 2 + s.length());
      |            ~~^~~~~~~~~~~~~~~~~
combo.cpp:80:17: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   80 |  if (s.length() == n) {
      |      ~~~~~~~~~~~^~~~
combo.cpp:85:6: error: 'press' was not declared in this scope
   85 |  if (press(s + other[0] + s + other[1]) == n) {
      |      ^~~~~