Submission #885825

#TimeUsernameProblemLanguageResultExecution timeMemory
885825sq00Combo (IOI18_combo)C++14
100 / 100
14 ms1948 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; string guess_sequence(int N) { string buttons = "", firstBtn = ""; int aCost = press("AX"); if(aCost == 2) { firstBtn = "A"; buttons = "BYX"; } else if(aCost == 1) { aCost = press("A"); if(aCost == 1) { firstBtn = "A"; buttons = "BYX"; } else { firstBtn = "X"; buttons = "ABY"; } } else { int bCost = press("B"); if(bCost == 1) { firstBtn = "B"; buttons = "AYX"; } else { firstBtn = "Y"; buttons = "ABX"; } } string current = firstBtn; if(current.size() == N) return current; while(true) { for(int i = 0; i < (int)buttons.size(); i++) { string test = current + buttons[i]; if(test.size() < N) { for(int j = 0; j < (int)buttons.size(); j++) { test += current + buttons[i + 1] + buttons[j]; } } int cost = press(test); if(cost == current.size() + 1) { current += buttons[i]; break; } else if(cost == current.size() + 2) { current += buttons[i + 1]; break; } else if(current.size() + 1 < N) { current += buttons[i + 2]; break; } if(i == 1) { current += buttons[2]; break; } } if(current.size() == N) break; } return current; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:32:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   32 |     if(current.size() == N) return current;
      |        ~~~~~~~~~~~~~~~^~~~
combo.cpp:36:28: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |             if(test.size() < N) {
      |                ~~~~~~~~~~~~^~~
combo.cpp:42:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |             if(cost == current.size() + 1) {
      |                ~~~~~^~~~~~~~~~~~~~~~~~~~~
combo.cpp:45:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |             } else if(cost == current.size() + 2) {
      |                       ~~~~~^~~~~~~~~~~~~~~~~~~~~
combo.cpp:48:42: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   48 |             } else if(current.size() + 1 < N) {
      |                       ~~~~~~~~~~~~~~~~~~~^~~
combo.cpp:57:27: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   57 |         if(current.size() == N) break;
      |            ~~~~~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...