Submission #1015905

#TimeUsernameProblemLanguageResultExecution timeMemory
1015905deeraCombo (IOI18_combo)C++14
100 / 100
18 ms2168 KiB
#include <bits/stdc++.h> using namespace std; int press(string p); #include "combo.h" string guess_sequence(int N) { int a = press("AB"); int b = press("BX"); string f = ""; if (a == 2) a--; if (b == 2) b--; if (a == 1 && b == 1) { f += "B"; } if (a == 1 && b == 0) { f += "A"; } if (a == 0 && b == 1) { f += "X"; } if (a == 0 && b == 0) { f += "Y"; } if (f.size() == N) { return f; } vector<string> r; if (f != "A") r.push_back("A"); if (f != "B") r.push_back("B"); if (f != "X") r.push_back("X"); if (f != "Y") r.push_back("Y"); while (true) { string g = f + r[0] + f + r[1] + r[0] + f + r[1] + r[1] + f + r[1] + r[2]; if (g.size() > N * 4) { break; } else { int p = press(g); if (p == f.size()) { f += r[2]; } else if (p == f.size() + 1) { f += r[0]; } else if (p == f.size() + 2) { f += r[1]; } } } // guessing the last character int x = press(f + r[0] + f + r[1]) - f.size(); int y = press(f + r[0] + f + r[2]) - f.size(); if (x == 1 && y == 1) { f += r[0]; } if (x == 1 && y == 0) { f += r[1]; } if (x == 0 && y == 1) { f += r[2]; } if (x == 0 && y == 0) { // shouldn't happen } return f; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:30:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   30 |     if (f.size() == N) {
      |         ~~~~~~~~~^~~~
combo.cpp:44:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   44 |         if (g.size() > N * 4) {
      |             ~~~~~~~~~^~~~~~~
combo.cpp:48:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |             if (p == f.size()) {
      |                 ~~^~~~~~~~~~~
combo.cpp:50:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |             } else if (p == f.size() + 1) {
      |                        ~~^~~~~~~~~~~~~~~
combo.cpp:52:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |             } else if (p == f.size() + 2) {
      |                        ~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...