Submission #731328

#TimeUsernameProblemLanguageResultExecution timeMemory
731328petezaCombo (IOI18_combo)C++14
100 / 100
38 ms648 KiB
#include <bits/stdc++.h> using namespace std; int press(string p); string str, toq; char chrs[5] = "ABXY"; string guess_sequence(int N) { if(press("AB")) { if(press("A")) str = 'A'; else str = 'B'; } else { if(press("X")) str = 'X'; else str = 'Y'; } if(N == 1) return str; for(int i=0;i<=2;i++) if(str[0] == chrs[i]) swap(chrs[i], chrs[i+1]); for(int i=0;i<N-2;i++) { toq = str + chrs[0] + chrs[0] + str + chrs[0] + chrs[1] + str + chrs[0] + chrs[2] + str + chrs[1]; int req = press(toq); if(req == str.size()) str += chrs[2]; else if(req == str.size() + 1) str += chrs[1]; else str += chrs[0]; } for(int i=0;i<2;i++) { if(press(str + chrs[i]) == N) return str + chrs[i]; } return str + chrs[2]; } /* int press(string p) { cout << p; int x; cin >> x; return x; } int main() {cout << guess_sequence(5);} */

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:22:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |         if(req == str.size()) str += chrs[2];
      |            ~~~~^~~~~~~~~~~~~
combo.cpp:23:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |         else if(req == str.size() + 1) str += chrs[1];
      |                 ~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...