제출 #220620

#제출 시각아이디문제언어결과실행 시간메모리
220620Coroian_DavidCombo (IOI18_combo)C++11
5 / 100
1 ms200 KiB

#include "combo.h"
std::string guess_sequence(int N) {
    using namespace std;

    string s;
    s.clear();

    char ch[4] = {'A', 'B', 'X', 'Y'};

    int poz = 0;
    int x = press("AB");
    if(x >= 1)
    {
        int y = press("A");
        poz = (y == 1 ? 0 : 1);
    }

    else
    {
        int y = press("X");
        poz = (y == 1 ? 2 : 3);
    }

    swap(ch[0], ch[poz]);

    s.resize(1);
    s[0] = ch[0];


    string a;
    a.clear();
    for(int i = 1; i < N - 1; i ++)
    {
        a = s + ch[2] +
            s + ch[3] + ch[1] +
            s + ch[3] + ch[2] +
            s + ch[3] + ch[3];


        int x = press(a) - i;
        s.resize(i + 1);
        s[i] = ch[1 + x];
    }

    x = press(s + ch[1] + s + ch[2]);
    if(x == N)
    {
        int y = press(s + ch[1]);
        s.resize(N);
        s[N - 1] = (y == N ? ch[1] : ch[2]);
    }

    else
    {
        s.resize(N);
        s[N - 1] = ch[3];
    }

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