Submission #654521

#TimeUsernameProblemLanguageResultExecution timeMemory
654521sofija6Combo (IOI18_combo)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#define ll long long
#include "combo.h"
using namespace std;
string guess_sequence(int N)
{
    string ans="",c="ABXY",a="";
    int x;
    int x=press("AB");
    if (x==2)
        ans+='A';
    else if (x)
    {
        x=press('A');
        if (x)
            ans+='A';
        else
            ans+='B';
    }
    else
    {
        x=press('X');
        if (x)
            ans+='X';
        else
            ans+='Y';
    }
    for (int i=0;i<4;i++)
    {
        if (ans[0]!=c[i])
            a+=c[i];
    }
    for (ll i=2;i<N;i++)
    {
        x=press(ans+a[0]+ans+a[1]+a[0]+ans+a[1]+a[1]+ans+a[1]+a[2]);
        if (x==i-1)
            ans+=a[2];
        else if (x==i)
            ans+=a[0];
        else
            ans+=a[1];
    }
    x=press(ans+a[0]);
    if (x==N)
        return ans+a[0];
    x=press(ans+a[1]);
    if (x==N)
        return ans+a[1];
    return ans+a[2];
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:9:9: error: redeclaration of 'int x'
    9 |     int x=press("AB");
      |         ^
combo.cpp:8:9: note: 'int x' previously declared here
    8 |     int x;
      |         ^
combo.cpp:14:17: error: could not convert ''A'' from 'char' to 'std::string' {aka 'std::__cxx11::basic_string<char>'}
   14 |         x=press('A');
      |                 ^~~
      |                 |
      |                 char
combo.cpp:22:17: error: could not convert ''X'' from 'char' to 'std::string' {aka 'std::__cxx11::basic_string<char>'}
   22 |         x=press('X');
      |                 ^~~
      |                 |
      |                 char