Submission #1146765

#TimeUsernameProblemLanguageResultExecution timeMemory
1146765kvintsekstakordCombo (IOI18_combo)C++20
0 / 100
0 ms408 KiB
#include "combo.h"
#include <bits/stdc++.h>

using namespace std;

string chars = "ABXY";

string guess_sequence(int N) {
  
  string S = "";
  if(press("AB")){
    S+=(press("A") ? 'A' : 'B');
  }else{
    S+=(press("X") ? 'X' : 'Y');
  }

  for(int i = 0; i < N-2; i++){
    vector<char> first;
    for(int j = 0; j < 4; j++){
      if(chars[j]==S[0]) continue;
      
      first.push_back(chars[j]);
    } 
    vector<string> opts;
    for(int j = 0; j < 4; j++){
      if(chars[j]==S[0]) continue;

      opts.push_back(S+to_string(first[0])+to_string(chars[j]));
    }
    opts.push_back(S+to_string(first[1]));

    int res = press(opts[0]+opts[1]+opts[2]+opts[3]);

    int sz = (int)S.size();

    if(res==sz+2) S+=first[0];
    else if(res==sz+1) S+=first[1];
    else S+=first[2];
  }

  vector<string> last;
  for(int j = 0; j < 4; j++){
    if(chars[j]==S[0]) continue;

    last.push_back(S+chars[j]);
  }
  if(press(last[0]+last[1])==N){
    if(press(last[0])==N){
      S=last[0];
    }else S=last[1];
  }else S=last[2];

  return S;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...