Submission #543039

#TimeUsernameProblemLanguageResultExecution timeMemory
543039OlympiaCombo (IOI18_combo)C++17
Compilation error
0 ms0 KiB
#include <vector> #include <algorithm> #include <iostream> #include <set> #include <cmath> #include <map> #include <random> #include <cassert> #include <ctime> #include <cstdlib> #include <limits.h> using namespace std; string oracle = "ABXYY"; bool isSubstring (string substr, string s) { for (int i = 0; i < s.length(); i++) { if (i + substr.length() - 1 < s.length() && s.substr(i, substr.length()) == substr) { return true; } } return false; } /* int press (string p) { cout << "QUERY " << p << '\n'; for (int i = 1; i <= oracle.size(); i++) { if (!isSubstring(oracle.substr(0, i), p)) { return i - 1; } } return oracle.size(); } */ string guess_sequence (int N) { string so_far = ""; if (press("AX") != 0) { if (press("A")) { so_far = "A"; } else { so_far = "X"; } } else { if (press("B")) { so_far = "B"; } else { so_far = "Y"; } } for (int i = 1; i < N; i ++) { vector<string> pos; for (string c: {"A", "B", "X", "Y"}) { if (so_far[0] != c[0]) { pos.push_back(c); } } string qry; for (string s: pos) { qry += so_far + pos[0] + s; } qry += so_far + pos[1]; int res = press(qry); if (res == so_far.size()) { so_far += pos[2]; } else if (res == so_far.size() + 1) { so_far += pos[1]; } else { so_far += pos[0]; } } return so_far; } /* int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); //cout << press("XXYYABYABXAY"); cout << guess_sequence(oracle.size()); } */

Compilation message (stderr)

combo.cpp: In function 'bool isSubstring(std::string, std::string)':
combo.cpp:16:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     for (int i = 0; i < s.length(); i++) {
      |                     ~~^~~~~~~~~~~~
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:36:9: error: 'press' was not declared in this scope
   36 |     if (press("AX") != 0) {
      |         ^~~~~
combo.cpp:61:19: error: 'press' was not declared in this scope; did you mean 'res'?
   61 |         int res = press(qry);
      |                   ^~~~~
      |                   res
combo.cpp:62:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |         if (res == so_far.size()) {
      |             ~~~~^~~~~~~~~~~~~~~~
combo.cpp:64:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |         } else if (res == so_far.size() + 1) {
      |                    ~~~~^~~~~~~~~~~~~~~~~~~~