Submission #930192

#TimeUsernameProblemLanguageResultExecution timeMemory
930192beabossCombo (IOI18_combo)C++14
5 / 100
1 ms664 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"; } 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:76:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   76 |     if (here == pref.size()) pref += lst;
      |         ~~~~~^~~~~~~~~~~~~~
combo.cpp:77:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   77 |     else if (here == pref.size() + 1) pref += ad;
      |              ~~~~~^~~~~~~~~~~~~~~~~~
combo.cpp:83:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   83 |   if (ab > pref.size()) {
      |       ~~~^~~~~~~~~~~~~
combo.cpp:85:28: 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 (press(pref + doub) > pref.size()) return pref + doub;
      |         ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...