Submission #659172

#TimeUsernameProblemLanguageResultExecution timeMemory
659172illyakrCombo (IOI18_combo)C++14
97 / 100
31 ms712 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; string ans = ""; void tr(string c1, string c2, string c3) { int cur = press(ans + c1 + ans + c2+c1 + ans + c2+c2 + ans + c2+c3); if (ans.size() == cur)ans.push_back(c3[0]); else if (ans.size() == cur - 1)ans.push_back(c1[0]); else if (ans.size() == cur - 2)ans.push_back(c2[0]); } string guess_sequence(int N) { int cur = 0; for (string c : {"A", "B", "X"}) { cur = press(c); if (cur == 1){ans = c;break;} } if (ans.empty())ans = "Y"; for (int id = 2; id < N; id++) { if (ans[0] == 'A')tr("B", "X", "Y"); if (ans[0] == 'B')tr("A", "X", "Y"); if (ans[0] == 'X')tr("A", "B", "Y"); if (ans[0] == 'Y')tr("A", "B", "X"); } if (ans.size() == N - 1) { int cnt = 0; for (string c : {"A", "B", "X", "Y"}) { if (c[0] == ans[0])continue; if (++cnt == 3)return ans + c; if (press(ans + c) == N)return ans + c; } } return ans; }

Compilation message (stderr)

combo.cpp: In function 'void tr(std::string, std::string, std::string)':
combo.cpp:9:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
    9 |     if (ans.size() == cur)ans.push_back(c3[0]);
      |         ~~~~~~~~~~~^~~~~~
combo.cpp:10:25: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   10 |     else if (ans.size() == cur - 1)ans.push_back(c1[0]);
      |              ~~~~~~~~~~~^~~~~~~~~~
combo.cpp:11:25: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   11 |     else if (ans.size() == cur - 2)ans.push_back(c2[0]);
      |              ~~~~~~~~~~~^~~~~~~~~~
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:28:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   28 |     if (ans.size() == N - 1) {
      |         ~~~~~~~~~~~^~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...