Submission #113371

#TimeUsernameProblemLanguageResultExecution timeMemory
113371AkashiCombo (IOI18_combo)C++14
5 / 100
1 ms292 KiB
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;

string guess_sequence(int N){
    int n = N, x;

    string s;
    set <char> let;

    let.insert({'A', 'B', 'X', 'Y'});

    char ch = 0;
    x = press(s + 'A' + s + 'B');
    if(x >= 1){
        x = press(s + 'A');
        if(x == 0) ch = 'B';
        else ch = 'A';
    }
    else{
        x = press(s + 'X');
        if(x == 0) ch = 'Y';
        else ch = 'X';
    }

    s.push_back(ch);
    let.erase(ch);
    cerr << ch;

    set <char> :: iterator it = let.begin();
    char A, B, C;

    A = *it; ++it; B = *it; ++it; C = *it;
    for(int i = 2; i < n ; ++i){
        int x = press(s + A + s + B + A + s + B + B + s + B + C);
        if(x == i - 1) {
            s.push_back(C);
            cerr << C;
        }
        else if(x == i){
            s.push_back(A);
            cerr << A;
        }
        else if(x == i + 1){
            s.push_back(B);
            cerr << B;
        }
    }

    ch = 0;
    x = press(s + 'A' + s + 'B');
    if(x == n){
        x = press(s + 'A');
        if(x == n - 1) ch = 'B';
        else ch = 'A';
    }
    else{
        x = press(s + 'X');
        if(x == n - 1) ch = 'Y';
        else ch = 'X';
    }
    cerr << ch;
    cerr << endl;
    s.push_back(ch);

    return s;
}


#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...