Submission #196920

#TimeUsernameProblemLanguageResultExecution timeMemory
196920Dilshod_ImomovCombo (IOI18_combo)C++17
0 / 100
2 ms320 KiB
#include <bits/stdc++.h>
#include "combo.h"

using namespace std;

char start( string &s )
{
  char c;
  if ( press("A") ) c = 'A';
  else if ( press("B") ) c = 'B';
  else if ( press("X") ) c = 'X';
  else c = 'Y';
  for ( auto i: "ABXY" ) {
    if ( i != c ) s += i;
  }
  return c;
}

char end( string S, string s, int N )
{
  if ( press( S + s[0] + S[1] ) == N ) {
    if ( press( S + s[0] ) == N ) return s[0];
    else return s[1];
  }
  return s[2];
}

string generate( string S, string s )
{
  return S + s[0] + S + s[1] + s[0] + S + s[1] + s[1] + S + s[1] + s[2];
}

string guess_sequence(int N) 
{
  string S, s, p;
  S += start(s);
  for ( int i = 1; i < N - 1; i++ ) {
    p = generate( S, s );
    int x = press(p);
    if ( x == i + 1 ) S += s[0];
    else if ( x == i ) S += s[2];
    else S += s[1];
  }
  if ( N != 1 )
    S += end(S, s, N);
  return S;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...