Submission #154060

#TimeUsernameProblemLanguageResultExecution timeMemory
154060nthoangCombo (IOI18_combo)C++11
5 / 100
4 ms300 KiB
#include <bits/stdc++.h>

#ifndef LOCAL
#include "combo.h"
#endif

#ifdef LOCAL
#include "/Users/nth842002/Library/debug.h"

const string answer = "YAX";

int press(string p) {
  int len = p.length();
  int coins = 0;
  for (int i = 0, j = 0; i < len; ++i) {
    if (j < 3 && answer[j] == p[i]) {
      ++j;
    } else if (answer[0] == p[i]) {
      j = 1;
    } else {
      j = 0;
    }
    coins = max(coins, j);
  }
  return coins;
}
#endif

using namespace std;

const string moves = "ABXY";

string guess_sequence(int n) {
  for (int mask = 0; mask < (1 << (n + n)); mask++) {
    string s;
    s.resize(n);
    for (int i = 0, t = mask; i < n; i++) {
      s[i] = moves[t % 4];
      t /= 4;
    }
    // debug(s);
    if (press(s) == n) {
      return s;
    }
  }
}

#ifdef LOCAL
int main() {
  debug(guess_sequence(3));
}
#endif

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:46:1: warning: control reaches end of non-void function [-Wreturn-type]
   46 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...