Submission #716895

#TimeUsernameProblemLanguageResultExecution timeMemory
716895Desh03콤보 (IOI18_combo)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
string guess_sequence(int n) {
    char first;
    string s;
    int x = press("AB");
    if (x == 2) {
        s = "AB";
        first = 'A';
    } else if (x) {
        int y = press("A");
        if (y) first = 'A', s = "A";
        else first = 'B', s = "B";
    } else {
        int y = press("X");
        if (y) first = 'X', s = "X";
        else first = 'Y', s = "Y";
    }
    while (1) {
        if (s.size() == n) return s;
        else if (s.size() <= n - 2) {
            if (first == 'A') {
                string p = s + "BB" + s + "BX" + s + "BY" + s + "X";
                int y = press(p), sz = s.size();
                if (y == sz + 2) {
                    s.push_back('B');
                } else if (y == sz + 1) {
                    s.push_back('X');
                } else s.push_back('Y');
            } else if (first == 'B') {
                string p = s + "AA" + s + "AX" + s + "AY" + s + "X";
                int y = press(p), sz = s.size();
                if (y == sz + 2) {
                    s.push_back('A');
                } else if (y == sz + 1) {
                    s.push_back('X');
                } else s.push_back('Y');
            } else if (first == 'X') {
                string p = s + "BB" + s + "BA" + s + "BY" + s + "A";
                int y = press(p), sz = s.size();
                if (y == sz + 2) {
                    s.push_back('B');
                } else if (y == sz + 1) {
                    s.push_back('A');
                } else s.push_back('Y');
            } else {
                string p = s + "BB" + s + "BA" + s + "BX" + s + "A";
                int y = press(p), sz = s.size();
                if (y == sz + 2) {
                    s.push_back('B');
                } else if (y == sz + 1) {
                    s.push_back('A');
                } else s.push_back('X');
            }
        } else {
            if (first == 'A') {
                string p = s + "B" + s + "X";
                int y = press(p);
                if (y == n - 1) {
                    s.push_back('Y');
                } else {
                    p = s + "B";
                    y = press(p);
                    if (y == n - 1) {
                        s.push_back('X');
                    } else s.push_back('B');
                }
            } else if (first == 'B') {
                string p = s + "A" + s + "X";
                int y = press(p);
                if (y == n - 1) {
                    s.push_back('Y');
                } else {
                    p = s + "A";
                    y = press(p);
                    if (y == n - 1) {
                        s.push_back('X');
                    } else s.push_back('A');
                }

            } else if (first == 'X') {
                string p = s + "B" + s + "A";
                int y = press(p);
                if (y == n - 1) {
                    s.push_back('Y');
                } else {
                    p = s + "B";
                    y = press(p);
                    if (y == n - 1) {
                        s.push_back('A');
                    } else s.push_back('B');
                }
            } else {
                string p = s + "B" + s + "A";
                int y = press(p);
                if (y == n - 1) {
                    s.push_back('X');
                } else {
                    p = s + "B";
                    y = press(p);
                    if (y == n - 1) {
                        s.push_back('A');
                    } else s.push_back('B');
                }
            }
        }
    }
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:6:13: error: 'press' was not declared in this scope
    6 |     int x = press("AB");
      |             ^~~~~
combo.cpp:20:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |         if (s.size() == n) return s;
      |             ~~~~~~~~~^~~~
combo.cpp:21:27: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   21 |         else if (s.size() <= n - 2) {
      |                  ~~~~~~~~~^~~~~~~~
combo.cpp:25:26: error: 'sz' was not declared in this scope; did you mean 's'?
   25 |                 if (y == sz + 2) {
      |                          ^~
      |                          s
combo.cpp:33:26: error: 'sz' was not declared in this scope; did you mean 's'?
   33 |                 if (y == sz + 2) {
      |                          ^~
      |                          s
combo.cpp:41:26: error: 'sz' was not declared in this scope; did you mean 's'?
   41 |                 if (y == sz + 2) {
      |                          ^~
      |                          s
combo.cpp:49:26: error: 'sz' was not declared in this scope; did you mean 's'?
   49 |                 if (y == sz + 2) {
      |                          ^~
      |                          s