Submission #1310336

#TimeUsernameProblemLanguageResultExecution timeMemory
1310336ycled_t12Combo (IOI18_combo)C++17
100 / 100
9 ms484 KiB
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;

string id = "ABXY";

string guess_sequence(int n){
  string ans = "";
  vector<bool> d(4);
  int c = press("AB");
  if(c == 0){
    c = press("X");
    if(c == 1){
      ans += "X";
      d[2] = true;

    }else{
      ans += "Y";
      d[3] = true;
    }
  }else{
    c = press("A");
    if(c == 1){
      ans += "A";
      d[0] = true;
    }else{
      ans += "B";
      d[1] = true;
    }
  }
  string new_id = "";
  for(int i = 0; i < 4; i++){
    if(d[i]) continue;
    new_id += id[i];
  }
  id = new_id;
  for(int i = 1; i < n; i++){
    if(i == n-1){
      ans += id[0];
      int c = press(ans);
      if(c == n){
        break;
      }
      ans.pop_back();
      ans += id[1];
      c = press(ans);
      if(c == n){
        break;
      }
      ans.pop_back();
      ans += id[2];
      break;
    }
    string fi = "";
    fi += ans;
    fi += id[0];
    ans += id[1];
    for(int y = 0; y < 3; y++){
      fi += ans;
      fi += id[y];
    }
    ans.pop_back();
    int c = press(fi);
    if(c == i){
      ans += id[2];
    }else if(c == i+1){
      ans += id[0];
    }else{
      ans += id[1];
    }
  }
  return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...