Submission #1010219

#TimeUsernameProblemLanguageResultExecution timeMemory
1010219baotoan655Combo (IOI18_combo)C++14
100 / 100
20 ms2084 KiB
#include <bits/stdc++.h> // #ifdef ONLINE_JUDGE #include "combo.h" // #endif #define file(name) if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); } #define FOR(i, a, b) for(int i = (a); i <= (b); ++i) #define FOD(i, b, a) for(int i = (b); i >= (a); --i) #define ll long long #define fi first #define se second using namespace std; string guess_sequence(int N) { string s; if(press("AB")) { if(press("A")) s = "A"; else s = "B"; } else { if(press("X")) s = "X"; else s = "Y"; } if(N == 1) return s; vector<string> ve; for(string str : {"A", "B", "X", "Y"}) if(str != s) ve.emplace_back(str); while(s.size() < N - 1) { // cout << s << ' '; string p; p = s; p += ve[0]; p += s; p += ve[1]; p += ve[0]; p += s; p += ve[1]; p += ve[1]; p += s; p += ve[1]; p += ve[2]; int res = press(p); int sz = s.size(); if(res == sz + 1) s += ve[0]; else if(res == sz + 2) s += ve[1]; else s += ve[2]; } if(press(s + ve[0]) == N) return s + ve[0]; else if(press(s + ve[1]) == N) return s + ve[1]; else return s + ve[2]; }

Compilation message (stderr)

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