Submission #1015831

#TimeUsernameProblemLanguageResultExecution timeMemory
1015831rythm_of_knightCombo (IOI18_combo)C++14
100 / 100
22 ms1604 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int n) { int x; char c; string a = "ABXY", ans; x = press("AB"); if (x) { x = press("A"); if (x) c = 'A'; else c = 'B'; } else { x = press("X"); if (x) c = 'X'; else c = 'Y'; } a.erase(a.begin() + a.find(c)); ans.push_back(c); if (n == 1) { return ans; } for (int i = 1; i < n - 1; i++) { string b = ans + a[1] + ans + a[0] + a[1] + ans + a[0] + a[0] + ans + a[0] + a[2]; x = press(b); if (x == ans.size() + 1) { ans.push_back(a[1]); } else if (x == ans.size() + 2) { ans.push_back(a[0]); } else { ans.push_back(a[2]); } } string b = ans + a[0] + ans + a[1]; x = press(b); if (x == ans.size() + 1) { b = ans + a[0]; x = press(b); if (x == ans.size() + 1) ans.push_back(a[0]); else ans.push_back(a[1]); } else { ans.push_back(a[2]); } return ans; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:32:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |         if (x == ans.size() + 1) {
      |             ~~^~~~~~~~~~~~~~~~~
combo.cpp:34:22: 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 (x == ans.size() + 2) {
      |                    ~~^~~~~~~~~~~~~~~~~
combo.cpp:42:11: 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 (x == ans.size() + 1) {
      |         ~~^~~~~~~~~~~~~~~~~
combo.cpp:45:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |         if (x == ans.size() + 1)
      |             ~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...