Submission #636990

#TimeUsernameProblemLanguageResultExecution timeMemory
636990bonkCombo (IOI18_combo)C++14
100 / 100
28 ms600 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; string guess_sequence(int n){ char tmpc[4] = {'A', 'B', 'X', 'Y'}; vector<char>c; int fi = 0; if(press("AB")){ if(press("A")) fi = 0; else fi = 1; } else{ if(press("X")) fi = 2; else fi = 3; } for(int i = 0; i < 4; i++){ if(fi != i) c.push_back(tmpc[i]); } string ans = ""; ans += tmpc[fi]; while(ans.length() < n){ if(ans.length() + 1 == n){ if(press(ans + c[0]) == n) ans += c[0]; else if(press(ans + c[1]) == n) ans += c[1]; else ans += c[2]; break; } string s = ans + c[0]; s += ans; s += c[1]; s += c[0]; s += ans; s += c[1]; s += c[1]; s += ans; s += c[1]; s += c[2]; int cur = press(s); if(cur == ans.length()) ans += c[2]; else if(cur == ans.length() + 1) ans += c[0]; else ans += c[1]; } return ans; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:26:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   26 |     while(ans.length() < n){
      |           ~~~~~~~~~~~~~^~~
combo.cpp:27:29: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   27 |         if(ans.length() + 1 == n){
      |            ~~~~~~~~~~~~~~~~~^~~~
combo.cpp:40:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         if(cur == ans.length()) ans += c[2];
      |            ~~~~^~~~~~~~~~~~~~~
combo.cpp:41:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         else if(cur == ans.length() + 1) ans += c[0];
      |                 ~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...