Submission #1346367

#TimeUsernameProblemLanguageResultExecution timeMemory
1346367comgaTramAnh콤보 (IOI18_combo)C++20
0 / 100
0 ms352 KiB
#include <bits/stdc++.h> 
#include "combo.h"
using namespace std; 
string guess_sequence(int N) {
  char ch[4] = {'A', 'B', 'X', 'Y'}; 
  string ret = "";
  string ask = "AB";  
  int len = press(ask); 
  if (len == 1) {
    len = press("A");
    if (len == 1) {
      ret = "A"; 
    }  
    else {
      ret = "B";
    }
  }
  else {
    len = press("X"); 
    if (len == 1) {
      ret = "X"; 
    }
    else {
      ret = "Y"; 
    }
  }
  vector <char> options; 
  for (int i = 0; i < 4; i++) {
    if (ch[i] != ret[0]) {
      options.push_back(ch[i]); 
    }
  }
  for (int i = 2; i + 2 <= N; i++) {
    ask = ret + options[0] + options[0] + ret + options[0] + options[1] + ret + options[0] + options[2] + ret + options[1]; 
    len = press(ask); 
    if (len == (int) ret.size() + 2) {
      ret += options[0];  
    }
    else if (len == (int) ret.size() + 1) {
      ret += options[1]; 
    }
    else {
      ret += options[2]; 
    }
  }
  ask = ret + options[0]; 
  len = press(ask); 
  if (len == N) {
    ret += options[0];
  }
  else {
    ask = ret + options[1]; 
    len = press(ask); 
    if (len == N) {
      ret += options[1]; 
    }
    else {
      ret += options[2]; 
    }
  } 
  return ret;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...