Submission #928612

#TimeUsernameProblemLanguageResultExecution timeMemory
928612AtabayRajabliCombo (IOI18_combo)C++17
100 / 100
13 ms1836 KiB
#include "combo.h" #include <bits/stdc++.h> std::string guess_sequence(int N) { std::string s = ""; std::string t = "ABXY"; int ind = 0; if(press("AB")) { if(press("A"))ind = 0; else ind = 1; } else { if(press("X"))ind = 2; else s = ind = 3; } s = t[ind]; t.erase(t.begin() + ind); for(int i = 1; i < N - 1; i++) { std::string c = (s + t[0]) + (s + t[1] + t[0]) + (s + t[1] + t[1]) + (s + t[1] + t[2]); int p = press(c); if(p == i + 1)s += t[0]; else if(p == i + 2)s += t[1]; else s += t[2]; } if(s.size() < N && press(s + "A" + s + "B") == N) { if(press(s + "A") == N)s += "A"; else s += "B"; } else if(s.size() < N) { if(press(s + "X") == N)s += "X"; else s += "Y"; } return s; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:31:17: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   31 |     if(s.size() < N && press(s + "A" + s + "B") == N)
      |        ~~~~~~~~~^~~
combo.cpp:36:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |     else if(s.size() < N)
      |             ~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...