제출 #476350

#제출 시각아이디문제언어결과실행 시간메모리
476350ponytailCombo (IOI18_combo)C++17
100 / 100
34 ms616 KiB
#include <bits/stdc++.h>
#include "combo.h"
 
using namespace std;
 
std::string guess_sequence(int N) {
    string S;
    if(press("AB")) {
        if(press("A")) {
            S += "A";
        }
        else {
            S += "B";
        }
    }
    else {
        if(press("X")) {
            S += "X";
        }
        else {
            S += "Y";
        }
    }
    string W = "ABXY", T;
    for(int i=0; i<4; i++) {
        if(S[0] != W[i]) T += W[i];
    }
    for(int i=1; i<N-1; i++) {
        string one = S + T[0];
        string q;
        for(int j=0; j<3; j++) {
            q += one;
            q += T[j];
        }
        q += S;
        q += T[1];
        q += S[0];
        int res = press(q);
        if(res == i + 2) S += T[0];
        else if(res == i + 1) S += T[1];
        else S += T[2];
    }
    if(N > 1) {
      if(press(S + T[0]) == N) S += T[0];
      else if(press(S + T[1]) == N) S += T[1];
      else S += T[2];
    }
    return S;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...