제출 #1356217

#제출 시각아이디문제언어결과실행 시간메모리
1356217Charizard2021콤보 (IOI18_combo)C++17
100 / 100
5 ms484 KiB
#include "combo.h"
#include<bits/stdc++.h>
using namespace std;
string pos = "ABXY";
string guess_sequence(int N){
    string S = "";
    if(press("AB") > 0){
        if(press("A") == 1){
            S += 'A';
        }
        else{
            S += 'B';
        }
    }
    else{
        if(press("X") == 1){
            S += 'X';
        }
        else{
            S += 'Y';
        }
    }
    if(N == 1){
        return S;
    }
    string other = "";
    for(int i = 0; i < 4; i++){
        if(pos[i] != S[0]){
            other += pos[i];
        }
    }
    for(int j = 1; j < N - 1; j++){
        char a = other[0];
        char b = other[1];
        char c = other[2];
        string s2 = "";
        s2 += S;
        s2 += a;
        s2 += S;
        s2 += b;
        s2 += a;
        s2 += S;
        s2 += b;
        s2 += b;
        s2 += S;
        s2 += b;
        s2 += c;
        int val = press(s2);
        if(val == (int)S.size()){
            S += c;
        }
        else{
            if(val == (int)S.size() + 1){
                S += a;
            }
            else{
                S += b;
            }
        }
    }
    for(int i = 0; i < 2; i++){
        string s2 = "";
        s2 += S;
        s2 += other[i];
        if(press(s2) == N){
            S += other[i];
            return S;
        }
    }
    S += other[2];
    return S;
}
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…