Submission #1077363

#TimeUsernameProblemLanguageResultExecution timeMemory
1077363asdasdqwerCombo (IOI18_combo)C++14
100 / 100
24 ms1920 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; std::string guess_sequence(int N) { string ret; int f1 = press("AB"); if (f1 == 0) { f1 = press("X"); if (f1 == 1) ret += "X"; else ret += "Y"; } else if (f1 == 1) { f1 = press("B"); if (f1 == 1) ret = "B"; else ret = "A"; } else ret = "AB"; vector<string> possible = {"A", "B", "X", "Y"}; possible.erase(std::find(possible.begin(), possible.end(), string(1, ret[0]))); while (ret.size()+1 < N) { string news = ret + possible[0]; for (int i=0;i<3;i++) { news += ret + possible[1] + possible[i]; } int code = press(news); if (code == ret.size()) ret += possible[2]; else if (code == ret.size()+1) ret += possible[0]; else ret += possible[1]; } if (ret.size() == N) return ret; string news = ret + possible[0] + ret + possible[1]; if (press(news) == N) { news = ret + possible[0]; if (press(news) == N) ret += possible[0]; else ret += possible[1]; } else ret += possible[2]; return ret; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:25:25: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   25 |     while (ret.size()+1 < N) {
      |            ~~~~~~~~~~~~~^~~
combo.cpp:33:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         if (code == ret.size()) ret += possible[2];
      |             ~~~~~^~~~~~~~~~~~~
combo.cpp:34:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         else if (code == ret.size()+1) ret += possible[0];
      |                  ~~~~~^~~~~~~~~~~~~~~
combo.cpp:38:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   38 |     if (ret.size() == N) return ret;
      |         ~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...