Submission #1346352

#TimeUsernameProblemLanguageResultExecution timeMemory
1346352421412412sfafa15Combo (IOI18_combo)C++20
Compilation error
0 ms0 KiB
#include <iostream>
using namespace std;
string guess_sequence(int N){
    string p;
    string chars[] = {"A","B","X","Y"};
    char char1; 
    char char2;
    char char2;


    if (int N == 3){
        for (int i = 0; i < 4; i ++){
            char1 = chars[i];
            for (int j = 0; j < 4; j ++){
                char2 = chars[j];
                for (int k = 0; k < 4; l ++){
                    char1 = chars[k];
                    p = char1 + char2 + char3;
                    if (press(p) == 3){
                        return p;
                    }
        }
        }
            
        }
        
    }




    return p;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:8:10: error: redeclaration of 'char char2'
    8 |     char char2;
      |          ^~~~~
combo.cpp:7:10: note: 'char char2' previously declared here
    7 |     char char2;
      |          ^~~~~
combo.cpp:11:15: error: expected initializer before '==' token
   11 |     if (int N == 3){
      |               ^~
combo.cpp:11:14: error: expected ')' before '==' token
   11 |     if (int N == 3){
      |        ~     ^~~
      |              )
combo.cpp:13:28: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'char' in assignment
   13 |             char1 = chars[i];
      |                     ~~~~~~~^
      |                            |
      |                            std::string {aka std::__cxx11::basic_string<char>}
combo.cpp:15:32: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'char' in assignment
   15 |                 char2 = chars[j];
      |                         ~~~~~~~^
      |                                |
      |                                std::string {aka std::__cxx11::basic_string<char>}
combo.cpp:16:40: error: 'l' was not declared in this scope
   16 |                 for (int k = 0; k < 4; l ++){
      |                                        ^
combo.cpp:17:36: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'char' in assignment
   17 |                     char1 = chars[k];
      |                             ~~~~~~~^
      |                                    |
      |                                    std::string {aka std::__cxx11::basic_string<char>}
combo.cpp:18:41: error: 'char3' was not declared in this scope; did you mean 'char2'?
   18 |                     p = char1 + char2 + char3;
      |                                         ^~~~~
      |                                         char2
combo.cpp:19:25: error: 'press' was not declared in this scope
   19 |                     if (press(p) == 3){
      |                         ^~~~~