Submission #1208357

#TimeUsernameProblemLanguageResultExecution timeMemory
1208357AvianshCombo (IOI18_combo)C++20
30 / 100
8 ms456 KiB
#include "combo.h"
#include <bits/stdc++.h>

using namespace std;

string guess_sequence(int n) {
    srand(time(0));
    //press();
    string curr = "AB";
    int c = press(curr);
    if(c==0){
        curr="X";
        if(press(curr)==0)
            curr="Y";
    }
    else if(c == 1){
        if(press("A")){
            curr="A";
        }
        else{
            curr="B";
        }
    }
    else{
        curr="A";
    }
    //curr has first character now;
    string chars = "";
    if(curr=="A"){
        chars="BXY";
    }
    else if(curr=="B"){
        chars="AXY";
    }
    else if(curr=="X"){
        chars="ABY";
    }
    else{
        chars="ABX";
    }
    //chars has the thingies now;
    for(int i = 1;i<n;i++){
        int ind = rand()%3;
        curr+=chars[ind];
        int up = rand()%2;
        if(up)
            ind++;
        else
            ind--;
        ind+=3;
        ind%=3;
        if(press(curr)==curr.size()){
            continue;
        }
        curr[curr.size()-1]=chars[ind];
        if(up)
            ind++;
        else
            ind--;
        ind+=3;
        ind%=3;
        if(press(curr)==curr.size()){
            continue;
        }
        curr[curr.size()-1]=chars[ind];
    }
    return curr;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...