제출 #769903

#제출 시각아이디문제언어결과실행 시간메모리
769903ByeWorldCombo (IOI18_combo)C++14
100 / 100
25 ms592 KiB
#include "combo.h"
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define ll long long
using namespace std;
typedef pair<int,int> pii;
typedef pair<pii, int> ipii;
const int MAXN = 1e3+100;

string ans, p;
int coin;
char sta;
char ch[4];

string guess_sequence(int N) {
    coin = press("AB");
    if(coin >= 1){
        coin = press("A");
        if(coin==1) sta = 'A';
        else sta = 'B';
    } else {
        coin = press("X");
        if(coin==1) sta = 'X';
        else sta = 'Y';
    }
    char nx = (sta=='A' ? 'B' : 'A');
    for(int i=0; i<=2; i++){
        ch[i] = nx;
        if(nx == 'A') nx = (sta=='B' ? 'X' : 'B');
        else if(nx == 'B') nx = (sta=='X' ? 'Y' : 'X');
        else if(nx == 'X') nx = 'Y';
    }
    ans = sta;
    if(N==1) return ans;

    for(int i = 2; i<=N-1; ++i) {
        p.clear();
        p = (ans+ch[0] + ch[0]); p += (ans+ch[0] + ch[1]); p += (ans+ch[0] + ch[2]);
        p += (ans + ch[1]);
        //cout << i << ' ' << p << " p\n";
        coin = press(p);

        char add;
        if(coin == i+1){ // a ato b
            add = ch[0];
        } else if(coin==i){
            add = ch[1];
        } else add = ch[2];
        ans += add;
    }

    coin = press(ans+ch[0]+ans+ch[1]);
    //cout << N << ' ' << ans+ch[0]+ans+ch[1] << " p\n";
    if(coin == N){
        coin = press(ans+ch[0]);
        if(coin==N) ans += ch[0];
        else ans += ch[1];
    } else {
        ans += ch[2];
    }
    return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...