Submission #306083

#TimeUsernameProblemLanguageResultExecution timeMemory
306083stoyan_malininCombo (IOI18_combo)C++14
100 / 100
37 ms592 KiB
#include "combo.h" //#include "grader.cpp" using namespace std; string guess_sequence(int N) { string ans = ""; if(press("AB")>0) { if(press("A")>0) ans += "A"; else ans += "B"; } else { if(press("X")>0) ans += "X"; else ans += "Y"; } if(N==1) return ans; string A = "A", B = "B", X = "X", Y = "Y"; if(ans[0]==B[0]) swap(A, B); if(ans[0]==X[0]) swap(A, X); if(ans[0]==Y[0]) swap(A, Y); for(int i = 1;i<N-1;i++) { string ask = ans+B+B+ans+B+X+ans+B+Y+ans+X; int res = press(ask) - ans.size(); if(res==0) ans += Y; else if(res==1) ans += X; else if(res==2) ans += B; } if(press(ans+"A"+ans+"B")>ans.size()) { if(press(ans+"A")>ans.size()) ans += "A"; else ans += "B"; } else { if(press(ans+"X")>ans.size()) ans += "X"; else ans += "Y"; } return ans; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:38:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     if(press(ans+"A"+ans+"B")>ans.size())
      |        ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
combo.cpp:40:26: 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(press(ans+"A")>ans.size()) ans += "A";
      |            ~~~~~~~~~~~~~~^~~~~~~~~~~
combo.cpp:45:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |         if(press(ans+"X")>ans.size()) ans += "X";
      |            ~~~~~~~~~~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...