Submission #1072582

#TimeUsernameProblemLanguageResultExecution timeMemory
1072582RigobertusCombo (IOI18_combo)C++17
0 / 100
1 ms344 KiB
#include <iostream> #include <algorithm> #include <vector> #include <map> #include <set> #include <queue> #include <string> //#define int long long #include "combo.h" using namespace std; string guess_sequence(int n) { string c[4] = {"A", "B", "X", "Y"}; string s; if (press("AB")) { s = "B"; if (press("A")) { s = "A"; } } else { s = "X"; if (press("Y")) { s = "Y"; } } vector<int> a; for (int i = 0; i < 4; i++) { if (c[i] != s) { a.push_back(i); } } if (n == 1) { return s; } while (s.size() < n - 1) { string p = s + c[a[0]]; for (int i = 0; i < 3; i++) { p += s + c[a[1]] + c[a[i]]; } int x = press(p); if (x == s.size()) { s += c[a[2]]; } else if (x == s.size() + 1) { s += c[a[0]]; } else { s += c[a[1]]; } } string ans = s; if (press(s + "A" + s + "B") == n) { ans = s + "A"; if (press(s + "B")) { ans = s + "B"; } } else { ans = s + "X"; if (press(s + "Y") == n) { ans = s + "Y"; } } return ans; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:38:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   38 |     while (s.size() < n - 1) {
      |            ~~~~~~~~~^~~~~~~
combo.cpp:44:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |         if (x == s.size()) {
      |             ~~^~~~~~~~~~~
combo.cpp:47:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |         else if (x == s.size() + 1) {
      |                  ~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...