Submission #114861

#TimeUsernameProblemLanguageResultExecution timeMemory
114861dsjongCombo (IOI18_combo)C++14
97 / 100
42 ms572 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("A")) s+='A'; else if(press("B")) 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:18:14: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   18 |   if(s.size()<N-1){
      |      ~~~~~~~~^~~~
combo.cpp:21:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |    if(ans==s.size()+2) s+=a[idx+1];
      |       ~~~^~~~~~~~~~~~
combo.cpp:22:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |    else if(ans==s.size()+1) s+=a[idx+2];
      |            ~~~^~~~~~~~~~~~
combo.cpp:28:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |    if(press(q)==s.size()+1){
      |       ~~~~~~~~^~~~~~~~~~~~
combo.cpp:30:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     if(press(q2)==s.size()+1) s+=a[idx+1];
      |        ~~~~~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...