제출 #1288810

#제출 시각아이디문제언어결과실행 시간메모리
1288810XJP12콤보 (IOI18_combo)C++20
0 / 100
1 ms332 KiB
#include <bits/stdc++.h>
using namespace std;
#include "combo.h"

string guess_sequence(int N){
    string buttons = "ABXY";
    string S = "";

    string first;
    for(char c : buttons){
        if(press(string(1, c)) > 0){
            first = c;
            break;
        }
    }
    string s1 = "";
    for(char c: buttons){
        if(c != S[0]) s1 += c;
    }

    int m = S.size();

    while(m < N){
        int k = S.size();

        string s2;
        s2 += S + s1[0]+ s1[0];

        s2 += S + s1[0] + s1[1]; 

        s2 += S + s1[0] + s1[2];

        int luis = press(s2);

        if(luis == k) S += s1[2];
        else if(luis == k+1) S += s1[1];
        else S += s1[0];
    }

    if ((int)S.size() < N) {
        for(char c : s1) {
            if(press(S + c) == N) {
                S += c;
                break;
            }
        }
    }

    return S;
}

#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...