답안 #1043381

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1043381 2024-08-04T08:58:51 Z BF001 비밀 (JOI14_secret) C++17
컴파일 오류
0 ms 0 KB
#include "secret.h"
#include<bits/stdc++.h>
using namespace std;
 
#define N 1005
#define K 15

int lf[K][N], rt[K][N], n;

void divi(int lv, int l, int r, int A[]){
    if (l == r){
        lf[lv][l] = A[l - 1];
        return;
    }
    int mid = (l + r) >> 1;
    lf[lv][mid] = A[mid - 1];
    for (int i = mid - 1; i >= l; i--){
        lf[lv][i] = Secret(A[i - 1], lf[lv][i + 1]);
    }
    rt[lv][mid + 1] = A[mid];
    for (int i = mid + 2; i <= r; i++){
        rt[lv][i] = Secret(A[i - 1], rt[lv][i - 1]);
    }

    divi(lv + 1, l, mid, A);
    divi(lv + 1, mid + 1, r, A);    
}
 
int get(int lv, int l, int r, int u, int v){
    int mid = (l + r) >> 1;
    if (u <= mid && r >= mid){
        int rt = lf[lv][u];
        if (v > mid) rt = Secret(rt, rt[lv][v]);
        return rt;
    }
    if (v < mid) return get(lv + 1, l, mid, u, v);
    return get(lv + 1, mid + 1, r, u, v);
}

void Init(int N, int A[]){
    n = N;
    divi(0, 1, n);
}

int Query(int L, int R){
    L++; R++;
    return get(0, 1, n, L, R);
}

Compilation message

secret.cpp: In function 'int get(int, int, int, int, int)':
secret.cpp:33:40: error: invalid types 'int[int]' for array subscript
   33 |         if (v > mid) rt = Secret(rt, rt[lv][v]);
      |                                        ^
secret.cpp: At global scope:
secret.cpp:5:11: error: expected ',' or '...' before numeric constant
    5 | #define N 1005
      |           ^~~~
secret.cpp:40:15: note: in expansion of macro 'N'
   40 | void Init(int N, int A[]){
      |               ^
secret.cpp: In function 'void Init(int)':
secret.cpp:42:17: error: too few arguments to function 'void divi(int, int, int, int*)'
   42 |     divi(0, 1, n);
      |                 ^
secret.cpp:10:6: note: declared here
   10 | void divi(int lv, int l, int r, int A[]){
      |      ^~~~