Submission #75871

#TimeUsernameProblemLanguageResultExecution timeMemory
75871kdh9949Combo (IOI18_combo)C++17
100 / 100
50 ms496 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; const static char b[5] = "ABXY"; static string r; static char a[3]; string guess_sequence(int N) { int x = press(string("XY")); int y = press(string("BY")); r += b[2 * !!x + !!y]; for(int i = 0, j = 0; i < 4; i++) if(i != 2 * !!x + !!y) a[j++] = b[i]; for(int x; r.length() < N - 1; ){ x = press(r + a[0] + a[0] + r + a[0] + a[1] + r + a[1] + a[0]); if(x == r.length()){ r += a[2]; continue; } if(x == r.length() + 1){ x = press(r + a[1] + r + a[1] + a[1]); if(x == r.length()){ r += a[0]; r += a[2]; } if(x == r.length() + 1){ r += a[1]; r += a[2]; } if(x == r.length() + 2){ r += a[1]; r += a[1]; } } else{ x = press(r + a[0] + r + a[0] + a[0]); if(x == r.length()){ r += a[1]; r += a[0]; } if(x == r.length() + 1){ r += a[0]; r += a[1]; } if(x == r.length() + 2){ r += a[0]; r += a[0]; } } } if(r.length() < N){ int x = press(r + "X" + r + "Y"); int y = press(r + "B" + r + "Y"); r += b[2 * (x - r.length()) + (y - r.length())]; } return r; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:15:27: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   15 |     for(int x; r.length() < N - 1; ){
      |                ~~~~~~~~~~~^~~~~~~
combo.cpp:17:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |         if(x == r.length()){ r += a[2]; continue; }
      |            ~~^~~~~~~~~~~~~
combo.cpp:18:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |         if(x == r.length() + 1){
      |            ~~^~~~~~~~~~~~~~~~~
combo.cpp:20:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |             if(x == r.length()){ r += a[0]; r += a[2]; }
      |                ~~^~~~~~~~~~~~~
combo.cpp:21:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |             if(x == r.length() + 1){ r += a[1]; r += a[2]; }
      |                ~~^~~~~~~~~~~~~~~~~
combo.cpp:22:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |             if(x == r.length() + 2){ r += a[1]; r += a[1]; }
      |                ~~^~~~~~~~~~~~~~~~~
combo.cpp:26:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |             if(x == r.length()){ r += a[1]; r += a[0]; }
      |                ~~^~~~~~~~~~~~~
combo.cpp:27:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |             if(x == r.length() + 1){ r += a[0]; r += a[1]; }
      |                ~~^~~~~~~~~~~~~~~~~
combo.cpp:28:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |             if(x == r.length() + 2){ r += a[0]; r += a[0]; }
      |                ~~^~~~~~~~~~~~~~~~~
combo.cpp:31:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   31 |     if(r.length() < N){
      |        ~~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...