Submission #211525

#TimeUsernameProblemLanguageResultExecution timeMemory
211525Harry464Combo (IOI18_combo)C++14
5 / 100
1 ms200 KiB
#include <iostream> #include <string> #include <cmath> #include "combo.h" using namespace std; string guess_sequence(int N) { char slovo[4]={'A','B','X','Y'}; int prvoSlovo, odgovor; string s; if(press("AB")) { if(press("A")) prvoSlovo=0; else prvoSlovo=1; } else { if(press("X")) prvoSlovo=2; else prvoSlovo=3; } s+=slovo[prvoSlovo]; for(int i=2;i<N;i++) { odgovor=press(s + slovo[(prvoSlovo+1)%4] + slovo[(prvoSlovo+1)%4] + s + slovo[(prvoSlovo+1)%4] + slovo[(prvoSlovo+2)%4] + s + slovo[(prvoSlovo+1)%4] + slovo[(prvoSlovo+3)%4] + s + slovo[(prvoSlovo+2)%4]); if(odgovor==s.size()) s+=slovo[(prvoSlovo+3)%4]; else if(odgovor==s.size()+1) s+=slovo[(prvoSlovo+2)%4]; else s+=slovo[(prvoSlovo+1)%4]; } if(press(s+"A"+s+"B")>s.size()) { if(press(s+"A")>s.size()) s+="A"; else s+="B"; } else { if(press(s+"X")>s.size()) s+="X"; else s+="Y"; } return s; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:33:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     if(odgovor==s.size()) s+=slovo[(prvoSlovo+3)%4];
      |        ~~~~~~~^~~~~~~~~~
combo.cpp:34:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     else if(odgovor==s.size()+1) s+=slovo[(prvoSlovo+2)%4];
      |             ~~~~~~~^~~~~~~~~~~~
combo.cpp:38:24: 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(s+"A"+s+"B")>s.size())
      |      ~~~~~~~~~~~~~~~~~~^~~~~~~~~
combo.cpp:40:20: 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(s+"A")>s.size()) s+="A";
      |        ~~~~~~~~~~~~^~~~~~~~~
combo.cpp:45:20: 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(s+"X")>s.size()) s+="X";
      |        ~~~~~~~~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...