Submission #630202

#TimeUsernameProblemLanguageResultExecution timeMemory
630202chubyxdxdCombo (IOI18_combo)C++17
100 / 100
32 ms592 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; std::string guess_sequence(int N) { string S= ""; if(press("AB")){ if(press("A"))S+='A'; else S+='B'; } else{ if(press("X"))S+='X'; else S+='Y'; } string g="ABXY"; string aux; for(int i=0;i<g.size();i++){ if(S[0]!=g[i])aux+=g[i]; } //cout<<aux<<endl; int ans=1; for(int i=1;i<N-1;i++){ int pos=press(S+aux[0]+S+aux[1]+aux[1]+S+aux[1]+aux[2]+S+aux[1]+aux[0]); if(pos==ans+1)S+=aux[0]; if(pos==ans)S+=aux[2]; if(pos==ans+2)S+=aux[1]; ans=S.size(); } //cout<<S<<endl; if(N>1){ if(press(S+aux[0])>S.size())S+=aux[0]; else{ //cout<<press(S+aux[1])<<endl; if(press(S+aux[1])>S.size())S+=aux[1]; else S+=aux[2]; }} //cout<<S<<endl; return S; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:17:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |   for(int i=0;i<g.size();i++){
      |               ~^~~~~~~~~
combo.cpp:31:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |   if(press(S+aux[0])>S.size())S+=aux[0];
      |      ~~~~~~~~~~~~~~~^~~~~~~~~
combo.cpp:34:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     if(press(S+aux[1])>S.size())S+=aux[1];
      |        ~~~~~~~~~~~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...