Submission #77113

#TimeUsernameProblemLanguageResultExecution timeMemory
77113kimjihoonCombo (IOI18_combo)C++14
100 / 100
41 ms492 KiB
#include "combo.h"
#include <iostream>
#include <string>
using namespace std;

std::string guess_sequence(int N) {
    int sr = 0;
    if (press("AB") > 0) sr += 2;
    if (press("AX") > 0) sr++;
    string sc[4] = {"Y", "X", "B", "A"};
    string s = "";
    s += sc[sr];
    string c[3];
    int cs = 0;
    for (int i = 0; i < 4; i++)
        if (i != sr){
            c[cs] = sc[i];
            cs++;
        }
    for (int i = 1; i < N; i++){
        string ts;
        if (i == N-1) ts = s + c[1] + s + c[2];
        else ts = s + c[1] + c[0] + s + c[2] + c[0] + s + c[2] + c[2];
        int t = press(ts) - s.length();
        if (t != 0 && i == N-1){
            int t1 = press(s + c[1]) - s.length();
            if (t1 == 0) s += c[2];
            else s += c[1];
            continue;
        }
        if (t == 0) s += c[0];
        else if (t == 1){
            string ps = s + c[1] + c[2];
            int t1 = press(ps) - s.length();
            if (t1 == 0) s += c[2] + c[1];
            else if (t1 == 1) s += c[1] + c[1];
            else s += c[1] + c[2];
            i++;
        }
        else{
            string ps = s + c[2] + c[0];
            int t1 = press(ps) - s.length();
            if (t1 == 0) s += c[1] + c[0];
            else if (t1 == 1) s += c[2] + c[2];
            else s += c[2] + c[0];
            i++;
        }
    }
    return s;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...