Submission #108456

#TimeUsernameProblemLanguageResultExecution timeMemory
108456redaCombo (IOI18_combo)C++14
100 / 100
55 ms556 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; string a="ABXY", b="AB", d, s; string guess_sequence(int n) { if(!press("AB")) b="XY"; char f=b[0]; if(!press(b.substr(0, 1))) f=b[1]; for(char c : a) if(c!=f)// the firs char appears only once d+=c; s+=f; if(n<=1) return s; while(s.size()<n-1) s+=d[press(s+d[1]+s+d[2]+d[0]+s+d[2]+d[1]+s+d[2]+d[2])-s.size()]; if(press(s+d[0]+s+d[1])>s.size()) {/*If the next character is 'B', then is s+1 returned. If it is 'X', then s+2is returned. If it is 'Y', then s is returned.*/ if(press(s+d[0])>s.size()) return s+d[0]; return s+d[1]; } return s+d[2]; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:18:16: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   18 |  while(s.size()<n-1)
      |        ~~~~~~~~^~~~
combo.cpp:20:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |  if(press(s+d[0]+s+d[1])>s.size()) {/*If the next character is 'B', then is s+1 returned. If it is 'X', then s+2is
      |     ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
combo.cpp:22:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |   if(press(s+d[0])>s.size())
      |      ~~~~~~~~~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...