Submission #777555

#TimeUsernameProblemLanguageResultExecution timeMemory
777555NeroZeinCombo (IOI18_combo)C++17
100 / 100
23 ms500 KiB
#include "combo.h" #include "bits/stdc++.h" using namespace std; string X = "ABXY"; std::string guess_sequence(int N) { string p; char first; string tmp = "AB"; if (press(tmp) > 0) { tmp = "A"; if (press(tmp) == 1) { first = 'A'; } else { first = 'B'; } } else { tmp = 'X'; if (press(tmp) == 1) { first = 'X'; } else { first = 'Y'; } } tmp = first; p += first; vector<string> st; for (int i = 0; i < 4; ++i) { for (int j = 0; j < 4; ++j) { if (X[i] == first || X[j] == first) { continue; } string t; t += X[i]; t += X[j]; st.push_back(t); } } auto ask = [&](string a, string b, string c) { string x = p + a + p + b + p + c; return press(x); }; vector<bool> vis(N); vis[0] = true; for (int i = 1; i + 1 < N; ) { int x = ask(st[0], st[1], st[3]); if (x == 2 + p.size()) { vis[i] = vis[i + 1] = true; int y = press(p + st[0]); if (y == 2 + p.size()) { p += st[0]; } else if (y == 1 + p.size()) { p += st[1]; } else { p += st[3]; } i += 2; } else if (x == 1 + p.size()) { vis[i] = vis[i + 1] = true; int y = press(p + st[4]); if (y == 2 + p.size()) { p += st[4]; } else if (y == 1 + p.size()) { p += st[5]; } else { p += st[2]; } i += 2; } else { vis[i] = true; p += st.back()[0]; i++; } } if (!vis.back()) { int cnt = 1; for (int i = 0; i < 4; ++i) { if (X[i] == first) continue; if (cnt == 3 || press(p + X[i]) == N) { p += X[i]; return p; } cnt++; } } return p; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:48:11: 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 (x == 2 + p.size()) {
      |         ~~^~~~~~~~~~~~~~~
combo.cpp:51:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |       if (y == 2 + p.size()) {
      |           ~~^~~~~~~~~~~~~~~
combo.cpp:53:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |       } else if (y == 1 + p.size()) {
      |                  ~~^~~~~~~~~~~~~~~
combo.cpp:59:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |     } else if (x == 1 + p.size()) {
      |                ~~^~~~~~~~~~~~~~~
combo.cpp:62:13: 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 (y == 2 + p.size()) {
      |           ~~^~~~~~~~~~~~~~~
combo.cpp:64:20: 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 (y == 1 + p.size()) {
      |                  ~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...