Submission #1117919

#TimeUsernameProblemLanguageResultExecution timeMemory
1117919adaawf콤보 (IOI18_combo)C++17
Compilation error
0 ms0 KiB
#include <iostream>
using namespace std;
/*int press(string s) {
    cout << s << endl;
    int k;
    cin >> k;
    return k;
}*/
char a[] = {'A', 'B', 'X', 'Y'};
string guess_sequence(int n) {
    int h = 0;
    if (press("AB")) {
        if (press("A")) h = 0;
        else h = 1;
    }
    else {
        if (press("X")) h = 2;
        else h = 3;
    }
    swap(a[h], a[3]);
    string s = ""; s += a[3];
    for (int i = 2; i < n; i++) {
        int h = press(s + a[0] + a[0] + s + a[1] + a[0] + s + a[1] + a[1] + s + a[1] + a[2]);
        h -= s.size();
        if (h == 0) s += a[2];
        else if (h == 1) s += a[0];
        else s += a[1];
    }
    if (press(s + a[0]) == n) return s + a[0];
    if (press(s + a[1]) == n) return s + a[1];
    return s + a[2];
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:12:9: error: 'press' was not declared in this scope
   12 |     if (press("AB")) {
      |         ^~~~~
combo.cpp:23:17: error: 'press' was not declared in this scope
   23 |         int h = press(s + a[0] + a[0] + s + a[1] + a[0] + s + a[1] + a[1] + s + a[1] + a[2]);
      |                 ^~~~~
combo.cpp:29:9: error: 'press' was not declared in this scope
   29 |     if (press(s + a[0]) == n) return s + a[0];
      |         ^~~~~
combo.cpp:30:9: error: 'press' was not declared in this scope
   30 |     if (press(s + a[1]) == n) return s + a[1];
      |         ^~~~~