제출 #1017142

#제출 시각아이디문제언어결과실행 시간메모리
1017142rakhim_ovaCombo (IOI18_combo)C++17
100 / 100
24 ms2016 KiB
#include "combo.h"
#include <bits/stdc++.h>


using namespace std;

using ll = long long;




char find_the_first_character(){
    if(press("AB")>=1){
        if(press("A")==1) return 'A';
        return 'B';
    }
    if(press("X")) return 'X';
    return 'Y';
}



/*

XAXXB

*/

string guess_sequence(int n) {
    char f=find_the_first_character();
    string just="ABXY", abxy="";
    string s="";
    s+=f;
    for(auto c: just){
        if(c==f) continue;
        abxy+=c;
    }
    
    int i=2;
    while(i<=n){
        string s1="";
        if(i+1<=n){
            s1+=s+abxy[0];
            s1+=s+abxy[1]+abxy[0];
            s1+=s+abxy[1]+abxy[1];
            s1+=s+abxy[1]+abxy[2];
            int coins=press(s1);
            if(coins==i) s+=abxy[0];
            else if(coins==i+1) s+=abxy[1];
            else s+=abxy[2];
        }
        else{
            if(press(s+abxy[0])==i){
                s+=abxy[0];
            }
            else if(press(s+abxy[1])==i){
                s+=abxy[1];
            }
            else{
                s+=abxy[2];
            }
        }
        i++;
    }
    // cout << s << '\n';
    return s;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...