Submission #713595

#TimeUsernameProblemLanguageResultExecution timeMemory
713595DennisTranCombo (IOI18_combo)C++17
100 / 100
41 ms488 KiB
#pragma GCC optimize("O2") #pragma GCC target("avx,avx2,fma") #include "combo.h" #include <bits/stdc++.h> #define FOR(i, a, b) for (int i = (a); i <= (b); i++) #define FOD(i, a, b) for (int i = (a); i >= (b); i--) #define REP(i, n) for (int i = 0; i < (n); i++) #define ALL(x) (x).begin(), (x).end() #define TIME (1.0 * clock() / CLOCKS_PER_SEC) #define file(name) if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); } using namespace std; const int MAXN = 2e5 + 5; string guess_sequence(int N) { if (N == 1) { if (press("A")) return "A"; if (press("B")) return "B"; if (press("X")) return "X"; return "Y"; } string T = "", S = ""; if (press("AB")) { if (press("A")) T += 'A'; else T += 'B'; } else { if (press("X")) T += 'X'; else T += 'Y'; } for (char c : {'A', 'B', 'X', 'Y'}) { if (c == T[0]) continue; T += c; } S = T[0]; while (S.size() < N - 1) { string ask = S + T[1] + T[1] + S + T[1] + T[2] + S + T[1] + T[3] + S + T[2]; int p = press(ask); if (p - 2 == S.size()) S += T[1]; else if (p - 1 == S.size()) S += T[2]; else S += T[3]; } if (press(S + T[1]) == N) return S + T[1]; else if (press(S + T[2]) == N) return S + T[2]; else return S + T[3]; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:40:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   40 |     while (S.size() < N - 1) {
      |            ~~~~~~~~~^~~~~~~
combo.cpp:43:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         if (p - 2 == S.size()) S += T[1];
      |             ~~~~~~^~~~~~~~~~~
combo.cpp:44:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |         else if (p - 1 == S.size()) S += T[2];
      |                  ~~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...