Submission #114862

#TimeUsernameProblemLanguageResultExecution timeMemory
114862dsjongCombo (IOI18_combo)C++14
100 / 100
58 ms460 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string a="ABXYABXY"; string s=""; string guess_sequence(int N){ int idx; if(press("AB")){ if(press("A")) s+='A'; else s+='B'; } else{ if(press("X")) s+='X'; else s+='Y'; } if(s[0]=='A') idx=0; else if(s[0]=='B') idx=1; else if(s[0]=='X') idx=2; else idx=3; for(int i=1;i<N;i++){ if(s.size()<N-1){ string q=s+a[idx+1]+a[idx+1]+s+a[idx+1]+a[idx+2]+s+a[idx+1]+a[idx+3]+s+a[idx+2]; int ans=press(q); if(ans==s.size()+2) s+=a[idx+1]; else if(ans==s.size()+1) s+=a[idx+2]; else s+=a[idx+3]; } else{ string q=s+a[idx+1]+s+a[idx+2]; string q2; if(press(q)==s.size()+1){ q2=s+a[idx+1]; if(press(q2)==s.size()+1) s+=a[idx+1]; else s+=a[idx+2]; } else{ s+=a[idx+3]; } } } return s; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:22:14: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   22 |   if(s.size()<N-1){
      |      ~~~~~~~~^~~~
combo.cpp:25:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |    if(ans==s.size()+2) s+=a[idx+1];
      |       ~~~^~~~~~~~~~~~
combo.cpp:26:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |    else if(ans==s.size()+1) s+=a[idx+2];
      |            ~~~^~~~~~~~~~~~
combo.cpp:32:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |    if(press(q)==s.size()+1){
      |       ~~~~~~~~^~~~~~~~~~~~
combo.cpp:34:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     if(press(q2)==s.size()+1) s+=a[idx+1];
      |        ~~~~~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...