Submission #374944

#TimeUsernameProblemLanguageResultExecution timeMemory
374944lakshith_Combo (IOI18_combo)C++14
100 / 100
56 ms688 KiB
#include "combo.h" std::string l; std::string guess_sequence(int n){ char start = ' '; std::string r = ""; if(press("AB")>=1){ if(press("A")>=1)start = 'A'; else start = 'B'; }else{ if(press("X")>=1)start = 'X'; else start = 'Y'; } if(start == 'A'){ r += 'A'; l = "BXY"; }else if(start == 'B'){ r += 'B'; l = "AXY"; }else if(start == 'X'){ r += 'X'; l = "BAY"; }else{ r += 'Y'; l = "ABX"; } if(n==1)return r; int k = 1; for(int i=1;i<n-1;i++){ std::string a,b,c,d; a = r + l[0]+l[0]; b = r + l[0]+l[1]; c = r + l[0]+l[2]; d = r + l[1]; int p = press(a+b+c+d); p -= k; if(p==0){ r += l[2]; }else if(p==1){ r += l[1]; }else { r += l[0]; } k++; } if(press(r+"A"+r+"B")>r.length()){ if(press(r+"A")>r.length())start = 'A'; else start = 'B'; }else{ if(press(r+"X")>r.length())start = 'X'; else start = 'Y'; } return r+start; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:48:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |         if(press(r+"A"+r+"B")>r.length()){
      |            ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
combo.cpp:49:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |    if(press(r+"A")>r.length())start = 'A';
      |       ~~~~~~~~~~~~^~~~~~~~~~~
combo.cpp:52:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |     if(press(r+"X")>r.length())start = 'X';
      |        ~~~~~~~~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...