제출 #839604

#제출 시각아이디문제언어결과실행 시간메모리
839604sleepntsheep콤보 (IOI18_combo)C++17
컴파일 에러
0 ms0 KiB
#include "combo.h"
#include <string>
#include <vector>
using namespace std;

#define BUT "ABXY"

string guess_sequence(int N)
{
    string ans(2005, 0);
    int j = 0;
    vector<int> non(2005, 0);

    for (int i = 0; i < 4; ++i)
    {
        if (i == 3)
            ans[0] = 'Y'; ++j;
        else
        {
            ans.resize(2);
            ans[0] = BUT[i];
            ans[1] = 'A';
            int k = press(ans);
            ans[1] = 0;
            if (k >= 1) ++j, non[1] |= 1;
            if (k == 2) ++j, ans[1] = 'A';
            if (k >= 1) break;
        }
    }

    for (int i = j; i < N;)
    {
        int nxt = i + 1;
        for (int j = 0; j < 4; j++)
        {
            if (j == 3)
                ans[i++] = 'Y';
            else
            {
                if (non[i] & (1 << j)) continue;
                ans.resize(i+2);
                ans[i] = BUT[j];
                ans[i+1] = i + 1 < N ? 'A' : 0;
                int k = press(ans);
                ans[i+1] = 0;
                if (k == i + 2) { non[i+1] |= 1; nxt = i + 2; ans[i+1] = 'A'; }
                if (k >= i + 1) goto FND;
            }
        }
FND:;
    i = nxt;
    }
    ans.resize(N);
    return ans;
}

컴파일 시 표준 에러 (stderr) 메시지

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:16:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   16 |         if (i == 3)
      |         ^~
combo.cpp:17:27: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   17 |             ans[0] = 'Y'; ++j;
      |                           ^~
combo.cpp:18:9: error: 'else' without a previous 'if'
   18 |         else
      |         ^~~~