Submission #345693

#TimeUsernameProblemLanguageResultExecution timeMemory
345693wwddCombo (IOI18_combo)C++14
100 / 100
46 ms564 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; std::string guess_sequence(int N) { const string rop[4] = {"A","B","X","Y"}; int ena = press("AB"); int of = 0; if(ena >= 1) { int enb = press("A"); if(enb) { of = 0; } else { of = 1; } } else { int enb = press("X"); if(enb) { of = 2; } else { of = 3; } } string op[4] = {rop[(of+1)%4],rop[(of+2)%4],rop[(of+3)%4],rop[of]}; char cop[4] = {op[0][0],op[1][0],op[2][0],op[3][0]}; string S = op[3]; while(S.size() < N-1) { int val = press(S+op[0]+S+op[1]+op[0]+S+op[1]+op[1]+S+op[1]+op[2]); if(val == S.size()+1) { S.push_back(cop[0]); } else if(val == S.size()+2) { S.push_back(cop[1]); } else { S.push_back(cop[2]); } } if(S.size() == N-1) { if(press(S+op[0]) == N) { S.push_back(cop[0]); } else if(press(S+op[1]) == N) { S.push_back(cop[1]); } else { S.push_back(cop[2]); } } return S; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:27:17: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   27 |  while(S.size() < N-1) {
      |        ~~~~~~~~~^~~~~
combo.cpp:29:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |   if(val == S.size()+1) {
      |      ~~~~^~~~~~~~~~~~~
combo.cpp:31:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |   } else if(val == S.size()+2) {
      |             ~~~~^~~~~~~~~~~~~
combo.cpp:37:14: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   37 |  if(S.size() == N-1) {
      |     ~~~~~~~~~^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...