Submission #86938

#TimeUsernameProblemLanguageResultExecution timeMemory
86938tjdgus4384Combo (IOI18_combo)C++14
Compilation error
0 ms0 KiB
#include<cstdio>
#include "combo.h"
#include<string>
#include<iostream>
using namespace std;
string x[4] = {"A", "B", "X", "Y"};

string guess_sequence(int n)
{
    string ans, s;
    if(press("AB"))
    {
        if(press("A")) f = 0;
        else f = 1;
    }
    else
    {
        if(press("X")) f = 2;
        else f = 3;
    }
    ans = x[f];
    for(int i = 0;i < 4;i++)
    {
        if(i == f) continue;
        s += x[i];
    }
    for(int i = 2;i < n;i++)
    {
        string p = ans + s[0] + s[0] + ans + s[0] + s[1] + ans + s[0] + s[2] + ans + s[1];
        int res = press(p);
        if(res == ans.length() + 2) ans += s[0];
        else if(res == ans.length() + 1) ans += s[1];
        else ans += s[2];
    }
    string p = ans + s[0] + ans + s[1];
    if(press(p))
    {
        p = ans + s[0];
        if(press(p)) ans += s[0];
        else ans += s[1];
    }
    else ans += s[2];
    return ans;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:13:24: error: 'f' was not declared in this scope
   13 |         if(press("A")) f = 0;
      |                        ^
combo.cpp:14:14: error: 'f' was not declared in this scope
   14 |         else f = 1;
      |              ^
combo.cpp:18:24: error: 'f' was not declared in this scope
   18 |         if(press("X")) f = 2;
      |                        ^
combo.cpp:19:14: error: 'f' was not declared in this scope
   19 |         else f = 3;
      |              ^
combo.cpp:21:13: error: 'f' was not declared in this scope
   21 |     ans = x[f];
      |             ^
combo.cpp:31:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |         if(res == ans.length() + 2) ans += s[0];
      |            ~~~~^~~~~~~~~~~~~~~~~~~
combo.cpp:32:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |         else if(res == ans.length() + 1) ans += s[1];
      |                 ~~~~^~~~~~~~~~~~~~~~~~~