Submission #113368

#TimeUsernameProblemLanguageResultExecution timeMemory
113368AkashiCombo (IOI18_combo)C++14
0 / 100
2 ms200 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);

    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 == 0) s.push_back(C);
        else if(x == 1) s.push_back(A);
        else if(x == 2) s.push_back(B);
    }

    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);

    return s;
}

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