Submission #534444

#TimeUsernameProblemLanguageResultExecution timeMemory
534444YaserFaisalCombo (IOI18_combo)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "combo.h"

using namespace std;

string call( string cur )
{
    int siz = cur.size()+1 ;
    if ( cur[0] == 'A' )
    {
        if ( press(cur+'B') == siz ) return cur+'B' ;
        else if ( press(cur+'X') == siz ) return cur+'X' ;
        else return cur+'Y' ;
    }
    if ( cur[0] == 'B' )
    {
        if ( press(cur+'A') == siz ) return cur+'A' ;
        else if ( press(cur+'X') == siz ) return cur+'X' ;
        else return cur+'Y' ;
    }
    if ( cur[0] == 'X' )
    {
        if ( press(cur+'B') == siz ) return cur+'B' ;
        else if ( press(cur+'A') == siz ) return cur+'A' ;
        else return cur+'Y' ;
    }
    if ( cur[0] == 'Y' )
    {
        if ( press(cur+'B') == siz ) return cur+'B' ;
        else if ( press(cur+'X') == siz ) return cur+'X' ;
        else return cur+'A' ;
    }
}

string guess_sequence (int n)
{
    string cur = "" ;
    if ( press('A') == 1 ) cur+='A' ;
    else if ( press('B') == 1 ) cur+='B' ;
    else if ( press('X') == 1 ) cur+='X' ;
    else cur+='Y' ;
    while(siz<n) cur = call(cur) ;
    return cur ;    
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:38:16: error: could not convert ''A'' from 'char' to 'std::string' {aka 'std::__cxx11::basic_string<char>'}
   38 |     if ( press('A') == 1 ) cur+='A' ;
      |                ^~~
      |                |
      |                char
combo.cpp:39:21: error: could not convert ''B'' from 'char' to 'std::string' {aka 'std::__cxx11::basic_string<char>'}
   39 |     else if ( press('B') == 1 ) cur+='B' ;
      |                     ^~~
      |                     |
      |                     char
combo.cpp:40:21: error: could not convert ''X'' from 'char' to 'std::string' {aka 'std::__cxx11::basic_string<char>'}
   40 |     else if ( press('X') == 1 ) cur+='X' ;
      |                     ^~~
      |                     |
      |                     char
combo.cpp:42:11: error: 'siz' was not declared in this scope; did you mean 'sin'?
   42 |     while(siz<n) cur = call(cur) ;
      |           ^~~
      |           sin
combo.cpp: In function 'std::string call(std::string)':
combo.cpp:33:1: warning: control reaches end of non-void function [-Wreturn-type]
   33 | }
      | ^