제출 #1236568

#제출 시각아이디문제언어결과실행 시간메모리
1236568em4ma2Combo (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 N=20;
// std::string S="ABYBXYBXYYBXYYYBXXYB";

// constexpr int MAX_N = 2000;
// constexpr int MAX_NUM_MOVES = 8000;

// int num_moves;

// void wrong_answer(const char *MSG) {
//   printf("Wrong Answer: %s\n", MSG);
//   exit(0);
// }

// 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";
    int x;
    //cout<<p<<endl;
    x=press(p);
    if (x>0){
        p="X";
        x=press(p);
        if (x==0){
            p="Y";
        }
    }else{
        p="A";
        x=press(p);
        if (x==0){
            p="B";
        }
    }
    string chs="ABXY";
    for (int i=0;i<4;i++){
        if (chs[i]==p[0])chs[i]='#';
    }
    string k;
    for (auto x:chs){
        if (x!='#')k.pb(x);
    }
    //cout<<k<<endl;
    int cnt=1;
    int tmp=n-2;
    int j=0;
    while (p.size()<n){
        string s=p+k[j]
                +p+k[j+1]+k[j]
                +p+k[j+1]+k[j+1]
                +p+k[j+1]+k[j+2];
        //cout<<"DSfj";
        x=press(s);
        //cout<<"DSfj";
        if (x==p.size()+0){
            p+=k[j+2];
        }else if (x==p.size()+1){
            p+=k[j];
        }else{
            p+=k[j+1];
        }
    }
    string s=p+k[j]
            +p+k[j+1];
    x=press(s);
    if (x==p.size()+1){
        s=p+k[j];
        x=press(s);
        if (x==cnt){
            s=p+k[j+1];
        }
    }else{
        s=p+k[j+2];
    }
    return s;
}

// int main(){
    
//     int n;
//     cin>>n;
//     cout<<guess_sequence(n)<<endl;
    

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