제출 #82749

#제출 시각아이디문제언어결과실행 시간메모리
82749hugo_pm콤보 (IOI18_combo)C++17
5 / 100
2 ms248 KiB
#include "combo.h"
#include <iostream>
using namespace std;

string S;
int N;
char ff;
string cc = "ABXY";
string test = "";

string guess_sequence(int locN)
{
    N = locN;
    int a1 = press("AB");

    if (a1 == 0) {
        int a2 = press("X");
        if (a2 == 0) S.push_back('Y');
        else S.push_back('X');
    } else {
        int a2 = press("A");
        if (a2 == 0) S.push_back('B');
        else S.push_back('A');
    }

    for (char c : cc) if (c != S[0]) test.push_back(c);

    for (int i = 1; i < N-1; ++i) {
        string p;
        p.append(S);
        p.push_back(test[0]);
        for (char c : test) {
            p.append(S);
            p.push_back(test[1]);
            p.push_back(c);
        }
        int cc = press(p);
        if (cc == i) {
            S.push_back(test[2]);
        } else if (cc == i+1) {
            S.push_back(test[0]);
        } else {
            S.push_back(test[1]);
        }
    }

    for (char c : test) {
        int x = press(S + c);
        if (x == N) { S.push_back(c); break; }
    }

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