Submission #1014750

#TimeUsernameProblemLanguageResultExecution timeMemory
1014750MrPavlitoCombo (IOI18_combo)C++17
100 / 100
24 ms1944 KiB
#include <bits/stdc++.h> #include "combo.h" #define pb push_back #define mp make_pair #define all(x) (x).begin(),(x).end() #define fi first #define sc second #define endl "\n" #define pii pair<int,int> using namespace std; std::string guess_sequence(int N) { string rez = ""; vector<string> slova; if(press("AB") > 0) { if(press("A") == 1) { rez = "A"; slova.pb("B"); slova.pb("X"); slova.pb("Y"); } else { rez = "B"; slova.pb("A"); slova.pb("X"); slova.pb("Y"); } } else { if(press("X") == 1) { rez = "X"; slova.pb("B"); slova.pb("A"); slova.pb("Y"); } else { rez = "Y"; slova.pb("B"); slova.pb("X"); slova.pb("A"); } } if(N==1)return rez; for(int i=0; i<N-2; i++) { string guess = rez+slova[0]+slova[0]+rez+slova[0]+slova[1]+rez+slova[0]+slova[2]+rez+slova[1]; int p = press(guess); if(p == rez.size()+2)rez+=slova[0]; else if(p == rez.size()+1)rez+=slova[1]; else rez+=slova[2]; } if(press(rez+slova[0]) == N)return rez+slova[0]; else if(press(rez+slova[1]) == N)return rez+slova[1]; else return rez+slova[2]; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:55:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |         if(p == rez.size()+2)rez+=slova[0];
      |            ~~^~~~~~~~~~~~~~~
combo.cpp:56:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |         else if(p == rez.size()+1)rez+=slova[1];
      |                 ~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...