제출 #1174532

#제출 시각아이디문제언어결과실행 시간메모리
1174532Seungni콤보 (IOI18_combo)C++20
컴파일 에러
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;
}

컴파일 시 표준 에러 (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];
      |                       ^