Submission #630469

#TimeUsernameProblemLanguageResultExecution timeMemory
630469NintsiChkhaidzeCombo (IOI18_combo)C++14
97 / 100
33 ms604 KiB
#include "combo.h"
#include <bits/stdc++.h>
#define pb push_back
using namespace std;

vector<char> v = {'A', 'B', 'X', 'Y'}, w;
string guess_sequence(int N) {
  string S = "";
  char f = v[3];

  for (int i = 0; i < 3; i++) {
    string P = S + v[i];
    if (press(P) == 1) {
      f = v[i];
      break;
    }
  }

  S += f;
  for (auto c : v)
    if (c != f)
      w.pb(c);

  while (S.size() < N - 1) {
    string p = S + w[0] + S + w[1] + w[0] + S + w[1] + w[1] + S + w[1] + w[2];
    int coins = press(p), s = S.size();
    if (coins == s)
      S += w[2];
    else if (coins == s + 1)
      S += w[0];
    else if (coins == s + 2)
      S += w[1];
  }

  if (N > 1) {
    char ls = w[2];
    for (int i = 0; i < 2; i++) {
      string P = S + w[i];
      if (press(P) == S.size() + 1) {
        ls = w[i];
        break;
      }
    }

    S += ls;
  }
  
  return S;
}

// ABXYBXXXXBY

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:24:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   24 |   while (S.size() < N - 1) {
      |          ~~~~~~~~~^~~~~~~
combo.cpp:39:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |       if (press(P) == S.size() + 1) {
      |           ~~~~~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...