Submission #76582

#TimeUsernameProblemLanguageResultExecution timeMemory
76582XylofoCombo (IOI18_combo)C++14
100 / 100
53 ms576 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int N) { string toL = "ABXY"; int fst = 0; fst += press("BY") ? 1 : 0; fst += press("XY") ? 2 : 0; string pre = ""; pre += toL[fst]; toL.erase(toL.begin() + fst); while(pre.size() + 2 <= N) { string query = "" + pre + toL[0] + pre + toL[1] + toL[0] + pre + toL[1] + toL[1] + pre + toL[1] + toL[2]; int k = press(query); if(k == pre.size()+0) pre += toL[2]; if(k == pre.size()+1) pre += toL[0]; if(k == pre.size()+2) pre += toL[1]; } if(pre.size() != N) { string query0 = pre + toL[0]; string query1 = pre + toL[1]; string query2 = pre + toL[2]; if(press(query0) == N) return query0; if(press(query1) == N) return query1; else return query2; } else { return pre; } }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:13:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   13 |   while(pre.size() + 2 <= N) {
      |         ~~~~~~~~~~~~~~~^~~~
combo.cpp:20:10: 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(k == pre.size()+0) pre += toL[2];
      |        ~~^~~~~~~~~~~~~~~
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(k == pre.size()+1) pre += toL[0];
      |        ~~^~~~~~~~~~~~~~~
combo.cpp:22:10: 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(k == pre.size()+2) pre += toL[1];
      |        ~~^~~~~~~~~~~~~~~
combo.cpp:24:17: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   24 |   if(pre.size() != N) {
      |      ~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...