Submission #1104902

#TimeUsernameProblemLanguageResultExecution timeMemory
1104902monaxiaCombo (IOI18_combo)C++17
100 / 100
28 ms1540 KiB
#include <bits/stdc++.h>
#include "combo.h"
#define pb push_back
#define ppb pop_back

using namespace std;

string guess_sequence(int n){
    string ans = "", temp = "ABXY";
    char ex = 'S';
    int cnt = 1;

    if(press("AB")){
        if(press("A")) ex = 'A';
        else ex = 'B';
    }

    else if(press("X")) ex = 'X';
    else ex = 'Y';

    ans.pb(ex);

    string newtemp = "";

    for(auto& x : temp) if(x != ex) newtemp.pb(x);

    while(cnt < n - 1){
        string uhh = ans;
        uhh.pb(newtemp[0]);
        uhh += ans;
        uhh.pb(newtemp[1]);
        uhh.pb(newtemp[0]);
        uhh += ans;
        uhh.pb(newtemp[1]);
        uhh.pb(newtemp[1]);
        uhh += ans;
        uhh.pb(newtemp[1]);
        uhh.pb(newtemp[2]);

        int val = press(uhh);

        if(val == cnt) ans.pb(newtemp[2]);
        if(val == cnt + 2) ans.pb(newtemp[1]);
        if(val == cnt + 1) ans.pb(newtemp[0]);

        cnt ++;
    }

    if(cnt == n) return ans;

    string uhh = ans;                      
    uhh.pb(newtemp[0]);
    uhh += ans;
    uhh.pb(newtemp[1]);

    if(press(uhh) - cnt >= 1){
        uhh = ans;
        uhh.pb(newtemp[0]);
        if(press(uhh) - cnt == 1) ans.pb(newtemp[0]);
        else ans.pb(newtemp[1]);
    }

    else ans.pb(newtemp[2]);

    return ans;
}  
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...