제출 #1043382

#제출 시각아이디문제언어결과실행 시간메모리
1043382BF001비밀 (JOI14_secret)C++17
컴파일 에러
0 ms0 KiB
#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 rtt = lf[lv][u]; if (v > mid) rtt = Secret(rt, rt[lv][v]); return rtt; } 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); }

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

secret.cpp: In function 'int get(int, int, int, int, int)':
secret.cpp:33:35: error: invalid conversion from 'int (*)[1005]' to 'int' [-fpermissive]
   33 |         if (v > mid) rtt = Secret(rt, rt[lv][v]);
      |                                   ^~
      |                                   |
      |                                   int (*)[1005]
In file included from secret.cpp:1:
secret.h:7:16: note:   initializing argument 1 of 'int Secret(int, int)'
    7 | int Secret(int X, int Y);
      |            ~~~~^
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[]){
      |      ^~~~