Submission #1125411

#TimeUsernameProblemLanguageResultExecution timeMemory
1125411ALTAKEXE콤보 (IOI18_combo)C++20
100 / 100
11 ms484 KiB
#include "combo.h"
#include<bits/stdc++.h>
#define ll long long 
#define F first 
#define S second 
using namespace std;
char ori[4]={'A','B','X','Y'};
int Pint(vector<int> v){
  string s="";
  for(auto x:v){
    s+=ori[x];
  }
  return press(s);
}

string guess_sequence(int N) {
  int l=0,r=3;
  while(l!=r){
    int m=(l+r)>>1;
    vector<int> v;
    for(int i=l;i<=m;i++){
      v.push_back(i);
    }
    if(Pint(v)){
      r=m;
    }else{
      l=m+1;
    }
  }
  string now="";
  now+=ori[l];
  for(int i=2;i<N;i++){
    int ct=press(now+ori[(l+1)%4]+now+ori[(l+2)%4]+ori[(l+1)%4]+now+ori[(l+2)%4]+ori[(l+2)%4]+now+ori[(l+2)%4]+ori[(l+3)%4]);
    if(ct==i){
      now+=ori[(l+1)%4];
    }else if(ct==i+1){
      now+=ori[(l+2)%4];
    }else {
      now+=ori[(l+3)%4];
    }
  }
  if(now.length()<N){
    for(int i=1;i<3;i++){
      if(press(now+ori[(l+i)%4])==N){
        now+=ori[(l+i)%4];
        break;
      }
    }
    if(now.length()<N){
      now+=ori[(l+3)%4];
    }
  }
  return now;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...