| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 1142386 | FZ_Laabidi | 콤보 (IOI18_combo) | C++20 | 0 ms | 0 KiB | 
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;
string guess_sequence(int n){
    string p = "";
    set<string> S;
    S.insert("A");
    S.insert("B");
    S.insert("X");
    S.insert("Y");
    string trash = "AB";
    int c = press(trash);
    if(c==1){
        c = press("A");
        if(c==1)p+="A";
        else p+="B";
    }
    else{
        c = press("X");
        if(c==1)p+="X";
        else p+="Y";
    }
    if(n==1)return p;
    S.erase(p);
    // Remaining letters up to the (n-1)th
    int c=0;
    string b,xx,y;
    for (auto x: S){
        if (c == 0) b = x;
        if (c == 1)  xx = x;
        if (c == 2) y = x;
        c++;
    }
    int count = 1;
    for(int i=0; i<n-1; i++){
        string t = p+b+p+xx+y+p+xx+xx+p+xx+b;
        c = press(t);
        if(c==count)p+=y;
        else if(c==count+1)p+=b;
        else p+=xx;
        count++;
    }
    string t = p+xx+p+b;
    c = press(t);
    if(c==n){
        c = press(p+xx);
        if(c==n)p+=xx;
        else p+=b;
    }
    else p+=y;
    return p;
}
