답안 #383849

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
383849 2021-03-30T21:54:54 Z JerryLiu06 비밀 (JOI14_secret) C++
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

int dat[10][1010], mask[1010], A[1010];

void divide(int L, int R, int lev, int A[]) {
    if (L == R) return ; int mid = (L + R) / 2;

    dat[lev][mid] = mid; for (int i = mid - 1; i >= L; i--) dat[lev][i] = Secret(A[i], dat[lev][i + 1]);
    dat[lev][mid + 1] = mid + 1; for (int i = mid + 2; i <= R; i++) dat[lev][i] = Secret(A[i], dat[lev][i - 1]);

    for (int i = mid + 1; i <= R; i++) mask[i] ^= (1 << lev);

    divide(L, mid, lev + 1, A); divide(mid + 1, R, lev + 1, A);
}
void Init(int N, int arr[]) { for (int i = 0; i < N; i++) A[i] = arr[i]; divide(1, N, 1, A); }

int Query(int L, int R) { if (L == R) return A[L];
    int lev = __builtin_ctz(mask[L] ^ mask[R]); return Secret(dat[lev][L], dat[lev][R]);
}

Compilation message

secret.cpp: In function 'void divide(int, int, int, int*)':
secret.cpp:8:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
    8 |     if (L == R) return ; int mid = (L + R) / 2;
      |     ^~
secret.cpp:8:26: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
    8 |     if (L == R) return ; int mid = (L + R) / 2;
      |                          ^~~
secret.cpp:10:75: error: 'Secret' was not declared in this scope
   10 |     dat[lev][mid] = mid; for (int i = mid - 1; i >= L; i--) dat[lev][i] = Secret(A[i], dat[lev][i + 1]);
      |                                                                           ^~~~~~
secret.cpp:11:83: error: 'Secret' was not declared in this scope
   11 |     dat[lev][mid + 1] = mid + 1; for (int i = mid + 2; i <= R; i++) dat[lev][i] = Secret(A[i], dat[lev][i - 1]);
      |                                                                                   ^~~~~~
secret.cpp: In function 'int Query(int, int)':
secret.cpp:20:56: error: 'Secret' was not declared in this scope
   20 |     int lev = __builtin_ctz(mask[L] ^ mask[R]); return Secret(dat[lev][L], dat[lev][R]);
      |                                                        ^~~~~~