제출 #740280

#제출 시각아이디문제언어결과실행 시간메모리
740280BidoTeima비밀 (JOI14_secret)C++17
0 / 100
468 ms8276 KiB
#include "secret.h" #include <bits/stdc++.h> const int N = 1e3; int val[N][N]; int a[N]; void rec(int l, int r){ if(l == r){ val[l][l] = a[l]; return; } int mid = (l + r) >> 1; // (l, mid), (l + 1, mid), ..., (mid, mid) int pre = a[l]; for(int i = l; i <= mid; i++){ if(i > l)pre = Secret(pre, a[i]); val[l][i] = pre; } pre = a[mid + 1]; for(int i = mid + 1; i <= r; i++){ if(i > mid + 1)pre = Secret(pre, a[i]); val[mid + 1][i] = pre; } rec(l, mid); rec(mid + 1, r); } void Init(int n, int A[]) { for(int i = 0; i < n; i++){ a[i] = A[i]; } memset(val, -1, sizeof(val)); rec(0, n - 1); } int Query(int L, int R) { if(L == R) return val[L][L]; for(int i = L; i <= R; i++){ if(val[L][i] != -1 && val[i + 1][R] != -1) return Secret(val[L][i], val[i + 1][R]); } return -1; }
#Verdict Execution timeMemoryGrader output
Fetching results...