Submission #1142053

#TimeUsernameProblemLanguageResultExecution timeMemory
1142053jokerCombo (IOI18_combo)C++17
Compilation error
0 ms0 KiB
#include "combo.h"
#include <unordered_set>
#include <unordered_map>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <iomanip>
#include <numeric>

using namespace std;
std::string guess_sequence(int N) {
  string S = "";
  vector<char> btns = ['X','Y','B','A'];
  int frstidx = -1;
  while (S.length() != N) {
    if (s.lenght() == 0) {
        for (let i = 0; i < 4; i++) {
            string st;
            st += btns[i];
            int coin = press(st);
            if (coin == 1) {
                frstidx = i;
                S += btns[i];
                break;
            }
        }
    } else {
        for (size_t i = 0; i < 4; i++) {
            if (i != frstidx) {
                string st = S+btns[i];
                int coin = press(st);
                if (coin == S.length()+1) {
                    S += btns[i];
                    break;
                }
            }
        }
    }
  }
  return S;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:15:24: error: expected identifier before 'X'
   15 |   vector<char> btns = ['X','Y','B','A'];
      |                        ^~~
combo.cpp:15:27: error: expected ']' before ',' token
   15 |   vector<char> btns = ['X','Y','B','A'];
      |                           ^
      |                           ]
combo.cpp: In lambda function:
combo.cpp:15:27: error: expected '{' before ',' token
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:15:27: error: conversion from 'guess_sequence(int)::<lambda()>' to non-scalar type 'std::vector<char>' requested
combo.cpp:15:28: error: expected unqualified-id before 'Y'
   15 |   vector<char> btns = ['X','Y','B','A'];
      |                            ^~~
combo.cpp:18:9: error: 's' was not declared in this scope
   18 |     if (s.lenght() == 0) {
      |         ^
combo.cpp:19:14: error: 'let' was not declared in this scope
   19 |         for (let i = 0; i < 4; i++) {
      |              ^~~
combo.cpp:19:25: error: 'i' was not declared in this scope
   19 |         for (let i = 0; i < 4; i++) {
      |                         ^