제출 #1224425

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

#define ll long long
#define pi pair<int, int>
#define pl pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()


string guess_sequence(int n) {
    string let;
    vector<string> add;
    string s;
    if (press("AB")) {
        if (press("A")) {
            s="A";
            let="BXY";
            add={"B","XB","XX","XY"};
        }
        else {
            s="B";
            let="AXY";
            add={"A","XA","XX","XY"};
        }
    }
    else {
        if (press("X")) {
            s="X";
            let="ABY";
            add={"A","BA","BB","BY"};
        }
        else {
            s="Y";
            let="ABX";
            add={"A","BA","BB","BX"};
        }
    }
    for (int i=1; i<n-1; i++) {
        string ss;
        for (int j=0; j<4; j++) {
            ss+=s+add[j];
        }
        int a=press(ss);
        if (a==i+1) {
            s+=let[0];
        }
        else if (a==i+2) {
            s+=let[1];
        }
        else {
            s+=let[2];
        }
    }
    if (n==1) {
        return s;
    }
    for (int i=0; i<2; i++) {
        if (press(s+let[i])==n) {
            return s+let[i];
        }
    }
    return s+let[2];
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...