Submission #967136

#TimeUsernameProblemLanguageResultExecution timeMemory
967136jamesbamberCombo (IOI18_combo)C++17
100 / 100
15 ms1984 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;

string guess_sequence(int N){
    string ans = "";
    if(press("AB") != 0){
        if(press("A") == 1) ans = "A";
        else ans = "B";
    }
    else{
        if(press("X") == 1) ans = "X";
        else ans = "Y";
    }

    if(N==1) return ans;

    string buttons = "";
    for(char c: "ABXY") if(c != ans[0]) buttons += c;

    for(int i=1; i<N-1; i++){

        string ilsus = ans + buttons[0] + ans + buttons[1] + buttons[0] + ans + buttons[1] + buttons[1] + ans + buttons[1] + buttons[2];
        int x = press(ilsus);
        if(x == ans.length()) ans += buttons[2];
        if(x == ans.length()+1) ans += buttons[0];
        if(x == ans.length()+2) ans += buttons[1];
        //cout << ilsus << " " << ans << endl;
    }

    if(press(ans + buttons[0]) == N) ans += buttons[0];
    else if(press(ans + buttons[1]) == N) ans += buttons[1];
    else ans += buttons[2];
    return ans;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:25:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |         if(x == ans.length()) ans += buttons[2];
      |            ~~^~~~~~~~~~~~~~~
combo.cpp:26:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         if(x == ans.length()+1) ans += buttons[0];
      |            ~~^~~~~~~~~~~~~~~~~
combo.cpp:27:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |         if(x == ans.length()+2) ans += buttons[1];
      |            ~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...