Submission #1174389

#TimeUsernameProblemLanguageResultExecution timeMemory
1174389SeungniCombo (IOI18_combo)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "combo.h"

using namespace std;

string cand = "ABXY";
string s;

string guess(string prefix)
{    
    string ret = "";
    ret += prefix;
    ret += s[0];

    for (int i = 0; i < 3; i++)
    {
        ret += prefix;
        ret += s[1];
        ret += s[i];
    }

    return ret;
}

string guess_sequence(int N)
{
    string S;
    string a = "A", b = "B", x = "X";

    int aa = press(a), bb = press(B), xx = press(x);
    if (aa)
        S = a;
    else if (bb)
        S = b;
    else if (xx)
        S = x;
    else
        S = "Y";

    char c = S[0];
    for (int i = 0; i < 4; i++)
    {
        if (cand[i] != c)
            s += cand[i];
    }

    for(int i = 0; i < N - 1; i++) {
        string ask = guess(S);
        int v = press(ask) - S.length();

        if(v == 1) S += s[0];
        else if(v == 2) S += s[1];
        else S += s[2];       
    }

    return S;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:30:35: error: 'B' was not declared in this scope
   30 |     int aa = press(a), bb = press(B), xx = press(x);
      |                                   ^
combo.cpp:35:14: error: 'xx' was not declared in this scope; did you mean 'x'?
   35 |     else if (xx)
      |              ^~
      |              x