제출 #916426

#제출 시각아이디문제언어결과실행 시간메모리
916426anango콤보 (IOI18_combo)C++17
0 / 100
1 ms344 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
/*std::string guess_sequence(int N) {
    std::string p = "";
    for (int i = 0; i < 4 * N; ++i) {
        p += 'A';
    }
    int coins = press(p);
    std::string S = "";
    for (int i = 0; i < N; ++i) {
        S += 'A';
    }
    return S;
}*/

string guess_sequence(int N) {
    string p="";
    int n=press("AB");
    char first;
    if (n>=1) {
        int m=press("A");
        if (m==1) {
            first='A';
        }
        else {
            first='B';
        }
        
    }
    else {
        int m=press("X");
        if (m==1) {
            first='X';
        }
        else {
            first='Y';
        }
    }
    string cur(1,first);
    set<string> others={"A", "B","X","Y"};
    vector<string> v;
    others.erase(cur);
    for (auto i:others) {
        v.push_back(i);
    }
    for (int i=1; i<=N; i++) {
        string guesseq="";
        for (int j=0; j<3; j++) {
            guesseq+=cur+v[0]+v[j];
        }
        guesseq+=cur+v[1];
        int ans=press(guesseq);
        if (ans==i) {
            cur+=v[2];
        }
        else if (ans==i+1) {
            cur+=v[1];
        }
        else {
            assert(ans==i+2);
            cur+=v[0];
        }
    }
    return cur;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...