Submission #1156890

#TimeUsernameProblemLanguageResultExecution timeMemory
1156890Owen11Combo (IOI18_combo)C++20
100 / 100
7 ms488 KiB
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;

// # define int long long
# define fir first
# define sec second
# define pb push_back
# define endl "\n"

string guess_sequence(int N) {
    char ch[3];
    string st;
    int asd = press("AB");
    if(asd) {
        int x = press("A");
        if(x) st = "A", ch[0] = 'B', ch[1] = 'X', ch[2] = 'Y';
        else st = "B", ch[0] = 'A', ch[1] = 'X', ch[2] = 'Y';
    }
    else {
        int x = press("X");
        if(x) st = "X", ch[0] = 'A', ch[1] = 'B', ch[2] =  'Y';
        else st = "Y", ch[0] = 'A', ch[1] = 'B', ch[2] = 'X';
    }

    for(int i = 2; i<N; i++) {
        string now = "";
        now += st; now.pb(ch[0]); now.pb(ch[0]);
        now += st; now.pb(ch[0]); now.pb(ch[1]);
        now += st; now.pb(ch[0]); now.pb(ch[2]);
        now += st; now.pb(ch[1]);
        int get = press(now);
        if(get == i+1) st.pb(ch[0]);
        else if(get == i) st.pb(ch[1]);
        else st.pb(ch[2]);
    }

    if(N > 1) {
        string  st0 = st; st0.pb(ch[0]);
        string  st1 = st; st1.pb(ch[1]);

        int x = press(st0);
        int y = press(st1);

        if(x == N) st.pb(ch[0]);
        else if(y == N) st.pb(ch[1]);
        else st.pb(ch[2]);
    }

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