Submission #980434

#TimeUsernameProblemLanguageResultExecution timeMemory
980434janson0109Combo (IOI18_combo)C++14
100 / 100
16 ms1920 KiB
#include <bits/stdc++.h>
#include <combo.h>
using namespace std;
 
string guess_sequence(int N) {
    string p = "";
    string pos;
    if(press("AB") >= 1) {
        if(press("A") == 1) {
            p += "A";
            pos = "BXY";
        } else {
            p += "B";
            pos = "AXY";
        }
    } else {
        if(press("X") == 1) {
            p += "X";
            pos = "ABY";
        } else {
            p += "Y";
            pos = "ABX";
        }
    }
    if(N==1) return p;
    for(int i=1; i<N-1; i++) {
        string guess = p + pos[0] + pos[0] + p + pos[0] + pos[1] + p + pos[0] + pos[2] + p + pos[1];
        int l = p.size();
        int length = press(guess);
        if(length == l) {
            p += pos[2];
        } else if(length == l+1) {
            p += pos[1];
        } else if(length == l+2) {
            p += pos[0];
        }
    }
    for (int i = 0; i < 2; i++){
        if (press(p+pos[i])==N) {
            return p+pos[i];
        }
    }
    return p+pos[2];
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...