Submission #589930

#TimeUsernameProblemLanguageResultExecution timeMemory
589930physics07Combo (IOI18_combo)C++17
100 / 100
34 ms604 KiB
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;
typedef long long ll;
string button[]={"A", "B", "X", "Y"};
string guess_sequence(int n) {
    string s="";
    int p=press("AB");
    if(p) s=(press("A")?"A":"B");
    else s=(press("X")?"X":"Y");
    string start=s;
    string first=(s[0]=='A'?"B":"A"), second=(s[0]=='X'?"Y":"X"), third;
    if(n>1) {
        for(int i=0; i<4; i++) if(!(button[i]==first || button[i]==second || button[i]==s)) third=button[i];
        for(int i=0; i<n-2; i++) {
            string q="";
            for(int j=0; j<4; j++) if(button[j]!=start) q+=s+first+button[j];
            q+=s+second;
            int p=press(q);
            if(p==(int)s.size()) s+=third;
            else if(p==(int)s.size()+1) s+=second;
            else s+=first;
        }
        string q=s+first+s+second;
        p=press(q);
        if(p==(int)s.size()) s+=third;
        else {
            q=s+first;
            if(press(q)==(int)s.size()) s+=second;
            else s+=first;
        }
    }
    return s;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...