제출 #1142524

#제출 시각아이디문제언어결과실행 시간메모리
1142524zakimoiCombo (IOI18_combo)C++20
100 / 100
7 ms508 KiB
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;
const int MAX = 1e9 + 7;
//vector<int> dp(MAX, MAX);
string guess_sequence(int N) {
    string firstchar;
    if (press("AB") != 0) {
    if (press("A") == 1) {firstchar = "A";}
    else {firstchar = "B";}
    }
    else {
    if (press("X") == 1) {firstchar = "X";}
    else {firstchar = "Y";}
    }
    if (N == 1) {
    return firstchar;
    }
    vector<string> possible = {"A", "B", "X", "Y"};
    possible.erase(remove(possible.begin(), possible.end(), firstchar), possible.end());
    string final = firstchar;
    for (int i = 0; i < N - 2; i++) {
        string sending = "";
        for (int j = 0; j < 3; j++) {
        sending += final + possible[0] + possible[j]; // will give i + 3
        }
        sending += final + possible[1]; // will give i + 2
        int resul = press(sending);
        if (resul == i+3) {
        final += possible[0];
        }
        else if (resul == i+2) {
        final += possible[1];
        }
        else {
        final += possible[2];
        }
    }
    if (press(final + possible[0] + final + possible[1]) == N) {
    if (press(final + possible[0]) == N) {return final + possible[0];}
    else {return final + possible[1];}
    }
    else {return final + possible[2];}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...