Submission #161088

#TimeUsernameProblemLanguageResultExecution timeMemory
161088giorgikobCombo (IOI18_combo)C++14
Compilation error
0 ms0 KiB
#include "combo.h"

std::string guess_sequence(int N) {
    std::string S = "";
    
    int x = press("AB");
    if(x == 1){
        x = press("A");
        if(x==1){
            S += 'A';
        } else {
            S += 'B';
        }
    } else {
        x = press("X");
        if(x==1){
            S += "X";
        } else {
            S += "Y";
        }
    }
    
    char c1,c2,c3;
    if(S=="X") c1 = "A", c2 = "B", c3 = "Y";
    if(S=="Y") c1 = "A", c2 = "B", c3 = "X";
    if(S=="A") c1 = "B", c2 = "X", c3 = "Y";
    if(S=="B") c1 = "A", c2 = "X", c3 = "Y";
    
    for(int i=1;i<N;i++){
        int x = (S+c1+S+c2+c1+S+c2+c2+S+c2+c3);
        if(x==S.size());
        S += c3;
        if(x==S.size()+1)
        S += c1;
        if(x==S.size()+2)
        S += c2;
    }
    
    return S;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:24:21: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   24 |     if(S=="X") c1 = "A", c2 = "B", c3 = "Y";
      |                     ^~~
      |                     |
      |                     const char*
combo.cpp:24:31: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   24 |     if(S=="X") c1 = "A", c2 = "B", c3 = "Y";
      |                               ^~~
      |                               |
      |                               const char*
combo.cpp:24:41: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   24 |     if(S=="X") c1 = "A", c2 = "B", c3 = "Y";
      |                                         ^~~
      |                                         |
      |                                         const char*
combo.cpp:25:21: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   25 |     if(S=="Y") c1 = "A", c2 = "B", c3 = "X";
      |                     ^~~
      |                     |
      |                     const char*
combo.cpp:25:31: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   25 |     if(S=="Y") c1 = "A", c2 = "B", c3 = "X";
      |                               ^~~
      |                               |
      |                               const char*
combo.cpp:25:41: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   25 |     if(S=="Y") c1 = "A", c2 = "B", c3 = "X";
      |                                         ^~~
      |                                         |
      |                                         const char*
combo.cpp:26:21: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   26 |     if(S=="A") c1 = "B", c2 = "X", c3 = "Y";
      |                     ^~~
      |                     |
      |                     const char*
combo.cpp:26:31: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   26 |     if(S=="A") c1 = "B", c2 = "X", c3 = "Y";
      |                               ^~~
      |                               |
      |                               const char*
combo.cpp:26:41: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   26 |     if(S=="A") c1 = "B", c2 = "X", c3 = "Y";
      |                                         ^~~
      |                                         |
      |                                         const char*
combo.cpp:27:21: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   27 |     if(S=="B") c1 = "A", c2 = "X", c3 = "Y";
      |                     ^~~
      |                     |
      |                     const char*
combo.cpp:27:31: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   27 |     if(S=="B") c1 = "A", c2 = "X", c3 = "Y";
      |                               ^~~
      |                               |
      |                               const char*
combo.cpp:27:41: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   27 |     if(S=="B") c1 = "A", c2 = "X", c3 = "Y";
      |                                         ^~~
      |                                         |
      |                                         const char*
combo.cpp:30:43: error: cannot convert 'std::__cxx11::basic_string<char>' to 'int' in initialization
   30 |         int x = (S+c1+S+c2+c1+S+c2+c2+S+c2+c3);
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
      |                                           |
      |                                           std::__cxx11::basic_string<char>
combo.cpp:31:13: 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(x==S.size());
      |            ~^~~~~~~~~~
combo.cpp:33:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         if(x==S.size()+1)
      |            ~^~~~~~~~~~~~
combo.cpp:35:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         if(x==S.size()+2)
      |            ~^~~~~~~~~~~~