Submission #930193

#TimeUsernameProblemLanguageResultExecution timeMemory
930193beabossCombo (IOI18_combo)C++14
100 / 100
15 ms2004 KiB
#include "combo.h" // Source: https://oj.uz/problem/view/IOI18_combo // #include "bits/stdc++.h" using namespace std; #define s second #define f first #define pb push_back typedef long long ll; typedef pair<int, int> pii; typedef vector<pii> vpii; typedef vector<int> vi; #define FOR(i, a, b) for (int i = (a); i<b; i++) bool ckmin(int& a, int b){ return b < a ? a = b, true : false; } bool ckmax(int& a, int b){ return b > a ? a = b, true : false; } string guess_sequence(int N) { int ab = press("AB"); string st = ""; string ad = ""; string doub; string lst; vector<string> pr; string poss = "ABXY"; if (ab) { if (press("A")) st= "A"; else st="B"; } else { if (press("X")) st= "X"; else st="Y"; } if (N == 1) return st; string pref = st; for (char a: poss) { if (a == st[0]) continue; if (ad == "") ad = a; else if (pr.size() == 0) { // cout << 'd' << endl; for (char b: poss) { if (b != st[0]) { string aa = string() + a; string bb = string() + b; pr.pb(aa + bb); // cout << "d" + a + b << endl; } } doub = a; } else lst = a; } // for (auto val: pr) cout << val << endl; // cout << ad << endl; // cout << pref << endl; assert(pr.size() == 3); FOR(i, 1, N-1) { string guess; guess += pref + ad; for (auto val: pr) guess += pref + val; // cout << pref << endl; int here = press(guess); if (here == pref.size()) pref += lst; else if (here == pref.size() + 1) pref += ad; else pref += doub; } // cout << pref << endl; ab = press(pref + doub + pref + lst); // cout << pref << ab << lst << endl; if (ab > pref.size()) { // cout << 'd' << endl; if (press(pref + doub) > pref.size()) return pref + doub; else return pref + lst; } else { return pref + ad; } // return pref; } // int main() { // ios::sync_with_stdio(false); // cin.tie(nullptr); // }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:78:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   78 |     if (here == pref.size()) pref += lst;
      |         ~~~~~^~~~~~~~~~~~~~
combo.cpp:79:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |     else if (here == pref.size() + 1) pref += ad;
      |              ~~~~~^~~~~~~~~~~~~~~~~~
combo.cpp:85:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   85 |   if (ab > pref.size()) {
      |       ~~~^~~~~~~~~~~~~
combo.cpp:87:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   87 |     if (press(pref + doub) > pref.size()) return pref + doub;
      |         ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...