Submission #78569

#TimeUsernameProblemLanguageResultExecution timeMemory
78569KLPPCombo (IOI18_combo)C++14
100 / 100
53 ms608 KiB
#include "combo.h" #include<iostream> using namespace std; std::string guess_sequence(int N) { string s=""; int p=press("AB"); if(p>0){ p=press("A"); if(p>0){ s+='A'; while(s.length()<N-1){ string h=s+"B"; h+=s+"XB"; h+=s+"XY"; h+=s+"XX"; int x=press(h); int y=s.length(); if(x==y){ s+='Y'; }else if(x==y+1){ s+='B'; }else{ s+='X'; } } if(N==1)return s; if(press(s+'X')>s.length()){ s+='X'; } else if(press(s+'B')>s.length()){ s+='B'; }else{ s+='Y'; } return s; } s+='B'; while(s.length()<N-1){ string h=s+"A"; h+=s+"XA"; h+=s+"XY"; h+=s+"XX"; int x=press(h); int y=s.length(); if(x==y){ s+='Y'; }else if(x==y+1){ s+='A'; }else{ s+='X'; } }if(N==1)return s; if(press(s+'X')>s.length()){ s+='X'; } else if(press(s+'A')>s.length()){ s+='A'; }else{ s+='Y'; } return s; } p=press("X"); if(p>0){ s+='X'; while(s.length()<N-1){ string h=s+"A"; h+=s+"BA"; h+=s+"BY"; h+=s+"BB"; int x=press(h); int y=s.length(); if(x==y){ s+='Y'; }else if(x==y+1){ s+='A'; }else{ s+='B'; } }if(N==1)return s; if(press(s+'B')>s.length()){ s+='B'; } else if(press(s+'A')>s.length()){ s+='A'; }else{ s+='Y'; } return s; } s+='Y'; while(s.length()<N-1){ string h=s+"A"; h+=s+"BA"; h+=s+"BX"; h+=s+"BB"; int x=press(h); int y=s.length(); if(x==y){ s+='X'; }else if(x==y+1){ s+='A'; }else{ s+='B'; } }if(N==1)return s; if(press(s+'B')>s.length()){ s+='B'; } else if(press(s+'A')>s.length()){ s+='A'; }else{ s+='X'; } return s; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:13:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   13 |    while(s.length()<N-1){
      |          ~~~~~~~~~~^~~~
combo.cpp:28:12: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   28 |            if(N==1)return s;
      |            ^~
combo.cpp:29:4: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   29 |    if(press(s+'X')>s.length()){
      |    ^~
combo.cpp:29:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |    if(press(s+'X')>s.length()){
      |       ~~~~~~~~~~~~^~~~~~~~~~~
combo.cpp:32:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |    else if(press(s+'B')>s.length()){
      |            ~~~~~~~~~~~~^~~~~~~~~~~
combo.cpp:41:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   41 |   while(s.length()<N-1){
      |         ~~~~~~~~~~^~~~
combo.cpp:56:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |   if(press(s+'X')>s.length()){
      |      ~~~~~~~~~~~~^~~~~~~~~~~
combo.cpp:59:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |   else if(press(s+'A')>s.length()){
      |           ~~~~~~~~~~~~^~~~~~~~~~~
combo.cpp:69:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   69 |   while(s.length()<N-1){
      |         ~~~~~~~~~~^~~~
combo.cpp:84:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   84 |   if(press(s+'B')>s.length()){
      |      ~~~~~~~~~~~~^~~~~~~~~~~
combo.cpp:87:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   87 |   else if(press(s+'A')>s.length()){
      |           ~~~~~~~~~~~~^~~~~~~~~~~
combo.cpp:95:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   95 |  while(s.length()<N-1){
      |        ~~~~~~~~~~^~~~
combo.cpp:110:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  110 |  if(press(s+'B')>s.length()){
      |     ~~~~~~~~~~~~^~~~~~~~~~~
combo.cpp:113:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  113 |  else if(press(s+'A')>s.length()){
      |          ~~~~~~~~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...