Submission #963831

# Submission time Handle Problem Language Result Execution time Memory
963831 2024-04-15T18:54:36 Z Hezov Combo (IOI18_combo) C++17
Compilation error
0 ms 0 KB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
string guess_sequence(int N)
{
    string s = "";///Empty string.
    ///Find first character.
    if(press("AB"))
    {
        if(press("A"))
            s+="A";
        else s+="B";
    }
    else
    {
        if(press("X"))
            s+="X";
        else s+="Y";
    }
    ///First character found.
    char choices[3];
    int poz = 0;
    if(s[0]!='A')
        choices[poz++] = 'A';
    if(s[0]!='B')
        choices[poz++] = 'B';
    if(s[0]!='X')
        choices[poz++] = 'C';
    if(s[0]!='Y')
        choices[poz++] = 'Y';
    ///Now we have all the choices.
    for(int i = 2;i<N;i++)
    {
        string p=""; ///sA        sBA
        p =s + choices[0] + s + choices[1] + choices[0];
        /// sBB
        p = s + choices[1] + s + choices[1];
        /// sBC
        p = s + choices[1] + choices[2];
        if(press(p)==i)
            s+=choices[0];
        else if(press(p)==i+1)
            s+=choices[1];
        else s+=choices[2];
    }
    ///Now we need the last letter.
    if(press(s+choices[0])==N)
        s+=choices[0];
    else if(press+choices[1])==N)
        s+=choices[1];
    else s+=choices[2];
    return s;
}

Compilation message

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:49:18: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   49 |     else if(press+choices[1])==N)
      |             ~~~~~^~~~~~~~~~~
combo.cpp:49:30: error: expected primary-expression before '==' token
   49 |     else if(press+choices[1])==N)
      |                              ^~