Submission #321042

# Submission time Handle Problem Language Result Execution time Memory
321042 2020-11-10T17:33:23 Z gustason Combo (IOI18_combo) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#include "combo.h"

using namespace std;

string guess_sequence(int N) {
    string S = "", q;
    int x;

    if (press("AB") >= 1) {
        if (press("A") == 1) {
            S += 'A';
        } else {
            S += 'B';
        }
    } else {
        if (press("X") == 1) {
            S += 'X';
        } else {
            S += 'Y';
        }
    }

    int sz = 1;
    for(int i = 1; i < N-1; i++, sz++) {
        if (S[0] == 'A') {
            q = S + "B" + S + "XB" + S + "XX" + S + "XY";
            x = press(q);
            if (x == sz) {
                S += "Y";
            } else if (x == sz + 1) {
                S += "B";
            } else {
                S += "X";
            }
        } else if (S[0] == 'B') {
            q = S + "A" + S + "XA" + S + "XX" + S "XY";
            x = press(q);
            if (x == sz) {
                S += "Y";
            } else if (x == sz + 1) {
                S += "A";
            } else {
                S += "X";
            }
        } else if (S[0] == 'X') {
            q = S + "A" + S + "BA" + S + "BB" + S "BY";
            x = press(q);
            if (x == sz) {
                S += "Y";
            } else if (x == sz + 1) {
                S += "A";
            } else {
                S += "B";
            }
        } else {
            q = S + "A" + S + "XA" + S + "XB" + S "XX";
            x = press(q);
            if (x == sz) {
                S += "B";
            } else if (x == sz + 1) {
                S += "A";
            } else {
                S += "X";
            }
        }
    }

    if (S[0] != 'A') {
        q = S + "A";
        x = press(q);
        if (x == N) return q;
    }
    if (S[0] != 'B') {
        q = S + "B";
        x = press(q);
        if (x == N) return q;
    }
    if (S[0] != 'X') {
        if (S[0] == 'Y') {
            S += 'X';
            return S;
        }
        q = S + "X";
        x = press(q);
        if (x == N) return q;
    }
    S += "Y";
    return S;
}

Compilation message

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:37:50: error: expected ';' before string constant
   37 |             q = S + "A" + S + "XA" + S + "XX" + S "XY";
      |                                                  ^~~~~
      |                                                  ;
combo.cpp:47:50: error: expected ';' before string constant
   47 |             q = S + "A" + S + "BA" + S + "BB" + S "BY";
      |                                                  ^~~~~
      |                                                  ;
combo.cpp:57:50: error: expected ';' before string constant
   57 |             q = S + "A" + S + "XA" + S + "XB" + S "XX";
      |                                                  ^~~~~
      |                                                  ;