제출 #1126108

#제출 시각아이디문제언어결과실행 시간메모리
1126108anmattroi비밀 (JOI14_secret)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "secret.h" using namespace std; int n; int a[1024]; int f[10][1024]; void Init(int N, int A[]) { n = N; int oldn = N; for (int i = 0; i < n; i++) a[i] = A[i]; while (__builtin_popcount(n) > 1) a[n++] = 0; int sz = __lg(n); for (int level = 0; level < sz; level++) { for (int block = 0; block < (1<<level); block++) { int start = (block<<(sz-level)), fin = ((block + 1) << (sz-level)); middle = (start+fin)>>1; if (start >= oldn) break; f[level][middle] = a[middle]; for (int x = middle+1; x < min(fin, oldn); x++) f[level][x] = Secret(f[level][x-1], a[x]); f[level][middle-1] = a[middle-1]; for (int x = middle - 2; x >= start;x--) f[level][x] = Secret(a[x], f[level][x+1]); } } } int Query(int L, int R) { if (L == R) return a[L]; int level = __lg(n)-__lg(L^R)-1; return Secret(f[level][L], f[level][R]); return 0; }

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

secret.cpp: In function 'void Init(int, int*)':
secret.cpp:20:17: error: 'middle' was not declared in this scope
   20 |                 middle = (start+fin)>>1;
      |                 ^~~~~~