Submission #580731

#TimeUsernameProblemLanguageResultExecution timeMemory
580731kkkkkkkkCombo (IOI18_combo)C++14
100 / 100
44 ms488 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int n) { string ans,v; if (press("AB")) { if (press("A")) ans="A",v="BXY"; else ans="B",v="AXY"; } else { if (press("X")) ans="X",v="ABY"; else ans="Y",v="ABX"; } if (n==1) return ans; for (int i=2;i<n;i++) { string f; f+=ans+v[0]+v[0]; //ABB , AXBB f+=ans+v[0]+v[1]; //ABBABX , AXBBAXBX f+=ans+v[0]+v[2]; //ABBABXABY , AXBBAXBXAXBY f+=ans+v[1]; //ABBABXABYAX , AXBBAXBXAXBYAXX int k=press(f); if (k==ans.size()+2) //mora da zapocnue so ABB,ABX ili ABY / AXBB,AXBX ili AXBY ans+=v[0]; else if (k==ans.size()+1) //mora da zapocnue so AX / AXX ans+=v[1]; else //zapocnue samo so A / AX ans+=v[2]; } if (press(ans+v[0])==ans.size()+1) ans+=v[0]; else if (press(ans+v[1])==ans.size()+1) ans+=v[1]; else ans+=v[2]; return ans; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:32:14: 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 (k==ans.size()+2) //mora da zapocnue so ABB,ABX ili ABY / AXBB,AXBX ili AXBY
      |             ~^~~~~~~~~~~~~~
combo.cpp:34:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         else if (k==ans.size()+1) //mora da zapocnue so AX / AXX
      |                  ~^~~~~~~~~~~~~~
combo.cpp:39:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     if (press(ans+v[0])==ans.size()+1)
      |         ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
combo.cpp:41:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     else if (press(ans+v[1])==ans.size()+1)
      |              ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...