Submission #420191

#TimeUsernameProblemLanguageResultExecution timeMemory
420191JasiekstrzCombo (IOI18_combo)C++17
100 / 100
43 ms672 KiB
#include<bits/stdc++.h> #include "combo.h" using namespace std; string guess_sequence(int N) { int n=N; string p; char bb; if(press("AB")>0) { if(press("A")>0) bb='A'; else bb='B'; } else { if(press("X")>0) bb='X'; else bb='Y'; } p=bb; char chr[3]={'A','B','X'}; for(int i=0;i<3;i++) { if(chr[i]==bb) chr[i]='Y'; } for(int i=1;i<n-1;i++) { string ask=p+chr[0]; for(int i=0;i<3;i++) ask+=p+chr[1]+chr[i]; int tmp=press(ask); if(tmp==p.size()) p+=chr[2]; else if(tmp==p.size()+1) p+=chr[0]; else p+=chr[1]; } if(n>1) { if(press(p+chr[0])>p.size()) p+=chr[0]; else if(press(p+chr[1])>p.size()) p+=chr[1]; else p+=chr[2]; } return p; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:36:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |   if(tmp==p.size())
      |      ~~~^~~~~~~~~~
combo.cpp:38:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |   else if(tmp==p.size()+1)
      |           ~~~^~~~~~~~~~~~
combo.cpp:45:21: 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(p+chr[0])>p.size())
      |      ~~~~~~~~~~~~~~~^~~~~~~~~
combo.cpp:47:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |   else if(press(p+chr[1])>p.size())
      |           ~~~~~~~~~~~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...