Submission #160288

#TimeUsernameProblemLanguageResultExecution timeMemory
160288MarcoMendoza1Combo (IOI18_combo)C++14
100 / 100
62 ms612 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; string r="",aux; char arr[4]; string guess_sequence(int n){ int ax1=press("AB"); if(ax1==1){ arr[1]='X'; arr[3]='Y'; if(press("A")){ arr[2]='B'; r="A"; }else{ arr[2]='A'; r="B"; } }else if(ax1==0){ arr[1]='A'; arr[2]='B'; if(press("X")){ arr[3]='Y'; r="X"; }else{ arr[3]='X'; r="Y"; } }else{ arr[1]='X'; arr[3]='Y'; arr[2]='B'; r="AB"; if(n==2){ return r; } } int ax; while(r.size()<(n-1)){ aux=r+arr[2]+r+arr[1]+arr[1]+r+arr[1]+arr[2]+r+arr[1]+arr[3]; ax=press(aux); if(ax==r.size()){ r=r+arr[3]; }else if(ax==(r.size()+1)){ r=r+arr[2]; }else{ r=r+arr[1]; } } if(n>1){ if(press(r+arr[1]+r+arr[2])==n){ if(press(r+arr[1])==n){ return r+arr[1]; }else{ return r+arr[2]; } }else{ return r+arr[3]; } }else{ return r; } }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:51:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   51 |     while(r.size()<(n-1)){
      |           ~~~~~~~~^~~~~~
combo.cpp:54:14: 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(ax==r.size()){
      |            ~~^~~~~~~~~~
combo.cpp:57:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |         }else if(ax==(r.size()+1)){
      |                  ~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...