Submission #1236491

#TimeUsernameProblemLanguageResultExecution timeMemory
1236491em4ma2Combo (IOI18_combo)C++20
0 / 100
0 ms408 KiB
#include <bits/stdc++.h>
#include "combo.h"
 
using namespace std;

#define pb push_back
#define ll long long

const int off=1<<19;
const int inf=1e9+4;
const int mxsz=2e5+4;

int q(int x,int y){
    cout<<"? "<<x<<" "<<y<<endl<<flush;
    int xx;
    cin>>xx;
    return xx;
}

void ans(char c){
    cout<<"! "<<c<<endl<<flush;
}

// int press(std::string p) {
//   if (++num_moves > MAX_NUM_MOVES) {
//     wrong_answer("too many moves");
//   }
//   int len = p.length();
//   if (len > 4 * N) {
//     wrong_answer("invalid press");
//   }
//   for (int i = 0; i < len; ++i) {
//     if (p[i] != 'A' && p[i] != 'B' && p[i] != 'X' && p[i] != 'Y') {
//       wrong_answer("invalid press");
//     }
//   }
//   int coins = 0;
//   for (int i = 0, j = 0; i < len; ++i) {
//     if (j < N && S[j] == p[i]) {
//       ++j;
//     } else if (S[0] == p[i]) {
//       j = 1;
//     } else {
//       j = 0;
//     }
//     coins = std::max(coins, j);
//   }
//   return coins;
// }

string guess_sequence(int n) {
    string p = "XY";
    //string ch[4]=["X","Y","A","B"];
    int x;
    x=press(p);
    if (x==1){
        p="X";
        x=press(p);
        if (x==0){
            p="Y";
        }
    }else{
        p="A";
        x=press(p);
        if (x==0){
            p="B";
        }
    }
    int cnt=1;
    int tmp=n-2;
    while (tmp--){
        string s=p;
        s+="X";
        s+=p+"Y"+"X";
        s+=p+"Y"+"Y";
        s+=p+"Y"+"A";
        x=press(s);
        if (x==cnt+0){
            p+="A";
        }else if (x==cnt+1){
            p+="X";
        }else{
            p+="Y";
        }
        cnt++;
    }
    string s=p;
    s+="X";
    s+=p+"Y";
    x=press(s);
    if (x==cnt+1){
        s=p+"X";
        x=press(s);
        if (x==cnt){
            s=p+"Y";
        }
    }else{
        s=p+"A";
    }
    return s;
}

// int main(){
    
    

//     return 0;
// }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...