Submission #1174532

#TimeUsernameProblemLanguageResultExecution timeMemory
1174532SeungniCombo (IOI18_combo)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; string cand = "ABXY"; string s; string guess(string prefix) { string ret = prefix; ret += s[0]; for (int i = 0; i < 3; i++) { ret += prefix; ret += s[1]; ret += s[i]; } return ret; } string guess_sequence(int N) { string S; string a = "A", b = "B", x = "X"; int aa = press(a), bb = press(b), xx = press(x); if (aa) S = a; else if (bb) S = b; else if (xx) S = x; else S = "Y"; char c = S[0]; for (int i = 0; i < 4; i++) { if (cand[i] != c) s += cand[i]; } for(int i = 0; i < N - 1; i++) { for(int j = 0; j < 3; j++) { string now = S + c[j]; int v = press(now); if(v >= S.length()) { S += c[j]; break; } } } return S; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:48:31: error: invalid types 'char[int]' for array subscript
   48 |             string now = S + c[j];
      |                               ^
combo.cpp:51:23: error: invalid types 'char[int]' for array subscript
   51 |                 S += c[j];
      |                       ^