제출 #594430

#제출 시각아이디문제언어결과실행 시간메모리
594430yutabi콤보 (IOI18_combo)C++14
5 / 100
1 ms212 KiB
#include "combo.h"


#include <bits/stdc++.h>
using namespace std;




std::string guess_sequence(int N)
{
    char start='A';

    char buttons[]={'A','B','X'};

    string ans="";

    string query="";

    if(press("AB"))
    {
        if(press("A"))
        {
            start='A';
        }

        else
        {
            start='B';
        }
    }

    else
    {
        if(press("X"))
        {
            start='X';
        }

        else
        {
            start='Y';
        }
    }

    if(buttons[0]==start)
    {
        swap(buttons[0],buttons[1]);
    }

    if(buttons[1]==start)
    {
        swap(buttons[2],buttons[1]);
    }

    if(buttons[2]==start)
    {
        buttons[2]='Y';
    }

    //cout << start << ' ' << buttons[0] << ' ' << buttons[1] << ' ' << buttons[2] << endl;

    ans=start;

    for(int i=1;i<N-1;i++)
    {
        query=ans;
        query+=buttons[0];
        query+=buttons[0];
        query+=ans;
        query+=buttons[0];
        query+=buttons[1];
        query+=ans;
        query+=buttons[0];
        query+=buttons[2];
        query+=ans;
        query+=buttons[1];

        //cout << query << endl;

        int res=press(query);

        if(res==i)
        {
            ans+=buttons[2];
        }

        if(res==i+1)
        {
            ans+=buttons[1];
        }

        if(res==i+2)
        {
            ans+=buttons[0];
        }
    }

    if(press(ans+buttons[0])==N)
    {
        ans+=buttons[0];
    }

    else if(press(ans+buttons[1])==N)
    {
        ans+=buttons[1];
    }

    else
    {
        ans+=buttons[2];
    }

    return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...