Submission #1351631

#TimeUsernameProblemLanguageResultExecution timeMemory
1351631Omar_GCombo (IOI18_combo)C++20
5 / 100
0 ms412 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;

string guess_sequence(int n) {
    string c = "ABXY", s = "";
    for (int i = 0; i < 3; i++) {
      string b = "";
      b += c[i];
        if (press(b)) {
            s = c[i];
            swap(c[i], c[3]);
            break;
        }
    }
    if (!s.size()) s = c[3];
    while (s.size() + 1 < n) {
        string q = s + c[0] + c[0] + s + c[0] + c[1] + s + c[0] + c[2] + s + c[1];
        int a = press(q);
        if (a == s.size() + 2) s += c[0];
        else if (a == s.size() + 1) s += c[1];
        else s += c[2];
    }
    for (int i = 0; i < 2; i++) {
        if (press(s + c[i]) == n) {
            return s+c[i];
        }
    }
    return s + c[2];
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...