Submission #776278

#TimeUsernameProblemLanguageResultExecution timeMemory
776278LoboCombo (IOI18_combo)C++17
100 / 100
28 ms592 KiB
#include "combo.h" #include<bits/stdc++.h> using namespace std; string guess_sequence(int N) { string ans; string a = "ABXY"; // for(int i = 0; i < 4; i++) { // if(i == 3) { // ans = a[i]; // a.erase(a.begin()+i,a.begin()+i+1); // break; // } // string ask; // ask+= a[i]; // if(press(ask)) { // ans = a[i]; // a.erase(a.begin()+i,a.begin()+i+1); // break; // } // } if(press(ans+a[0]+a[1]) > 0) { if(press(ans+a[0])) { ans = a[0]; a = "BXY"; } else { ans = a[1]; a = "AXY"; } } else { if(press(ans+a[2])) { ans = a[2]; a = "ABY"; } else { ans = a[3]; a = "ABX"; } } if(N == 1) return ans; for(int i = 1; i < N-1; i++) { string ask; ask = ans + a[0] + a[0]; ask+= ans + a[0] + a[1]; ask+= ans + a[0] + a[2]; ask+= ans + a[1]; int c = press(ask); if(c == ans.size()) ans+= a[2]; else if(c == ans.size()+1) ans+= a[1]; else if(c == ans.size()+2) ans+= a[0]; else assert(false); } if(press(ans+a[0]) == N) return ans+a[0]; else if(press(ans+a[1]) == N) return ans+a[1]; else return ans+a[2]; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:56:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |   if(c == ans.size()) ans+= a[2];
      |      ~~^~~~~~~~~~~~~
combo.cpp:57:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |   else if(c == ans.size()+1) ans+= a[1];
      |           ~~^~~~~~~~~~~~~~~
combo.cpp:58:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |   else if(c == ans.size()+2) ans+= a[0];
      |           ~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...