Submission #580460

#TimeUsernameProblemLanguageResultExecution timeMemory
580460VanillaCombo (IOI18_combo)C++17
30 / 100
57 ms464 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; string ord = "ABXY"; string guess_sequence(int N) { int a1 = press("AB"); int fr = 0; if (a1 == 0) { fr = 2; int a2 = press("XY"); if (a2 == 1) { int a3 = press("X"); if (!a3) fr = 3; } } else if (a1 == 1) { int a2 = press("A"); if (!a2) fr = 1; } if (fr == 1) ord = "BXYA"; else if (fr == 2) ord = "XYAB"; else if (fr == 3) ord = "YABX"; string rs = ""; rs.push_back(ord[0]); for (int i = 1; i < N; i++){ string nw = rs; nw.push_back(ord[1]); nw.push_back(ord[2]); int now = press(nw); if (now == nw.size()) { rs.push_back(ord[1]); rs.push_back(ord[2]); i++; } else if (now == nw.size() - 1) { rs.push_back(ord[1]); } else { nw.pop_back(); nw.pop_back(); nw.push_back(ord[2]); if (press(nw) == nw.size()) rs.push_back(ord[2]); else rs.push_back(ord[3]); } } return rs; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:30:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     if (now == nw.size()) {
      |         ~~~~^~~~~~~~~~~~
combo.cpp:35:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     else if (now == nw.size() - 1) {
      |              ~~~~^~~~~~~~~~~~~~~~
combo.cpp:41:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |       if (press(nw) == nw.size()) rs.push_back(ord[2]);
      |           ~~~~~~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...