Submission #754128

#TimeUsernameProblemLanguageResultExecution timeMemory
754128kirakaminski968Combo (IOI18_combo)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
string guess_sequence(int N){
    string ask = "AB"; string now = "";
    char arr[4] = {'A','B','X','Y'};
    int ok = press(ask), used;
    if(ok == 2){
        now += 'A';
        used = 0;
    }
    else if(ok == 1){
        ask = "A";
        ok = press(ask);
        if(ok == 1) {now += 'A'; used = 0;}
        else {now += 'B'; used = 1;}
    }
    else{
        ask = "X";
        ok = press(ask);
        if(ok == 1) {now += 'X'; used = 2;}
        else {now += 'Y'; used = 3;}
    }
    int add;
    if(used == 0) add = 1;
    else add = 0;
    //cout << used << " " << add << "\n";
    for(int i = 1;i<=N-2;++i){
        string ask;
        string cur = now + arr[add];
        int newc = -1, newc2 = -1;
        for(int j = 0;j<4;++j){
            if(j != used){
                ask += cur+arr[j];
                if(newc == -1 && j != add) newc = j;
                else if(j != add) newc2 = j;
            }
        }
        ask += now+arr[newc];
        ok = press(ask);
        if(ok == i+2){
            now += arr[add];
        }
        else if(ok == i+1){
            now += arr[newc];
        }
        else{
            now += arr[newc2];
        }
    }
    for(int i = 0;i<4;++i){
        if(i != used){
            ok = press(now+arr[i]);
            if(ok == N){
                return now+arr[i];
            }
        }
    }
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:6:14: error: 'press' was not declared in this scope
    6 |     int ok = press(ask), used;
      |              ^~~~~
combo.cpp:9:9: error: 'used' was not declared in this scope
    9 |         used = 0;
      |         ^~~~
combo.cpp:14:34: error: 'used' was not declared in this scope
   14 |         if(ok == 1) {now += 'A'; used = 0;}
      |                                  ^~~~
combo.cpp:15:27: error: 'used' was not declared in this scope
   15 |         else {now += 'B'; used = 1;}
      |                           ^~~~
combo.cpp:20:34: error: 'used' was not declared in this scope
   20 |         if(ok == 1) {now += 'X'; used = 2;}
      |                                  ^~~~
combo.cpp:21:27: error: 'used' was not declared in this scope
   21 |         else {now += 'Y'; used = 3;}
      |                           ^~~~
combo.cpp:24:8: error: 'used' was not declared in this scope
   24 |     if(used == 0) add = 1;
      |        ^~~~
combo.cpp:32:21: error: 'used' was not declared in this scope
   32 |             if(j != used){
      |                     ^~~~
combo.cpp:51:17: error: 'used' was not declared in this scope
   51 |         if(i != used){
      |                 ^~~~
combo.cpp:4:18: warning: control reaches end of non-void function [-Wreturn-type]
    4 |     string ask = "AB"; string now = "";
      |                  ^~~~