제출 #1263934

#제출 시각아이디문제언어결과실행 시간메모리
1263934tminhSecret (JOI14_secret)C++20
0 / 100
341 ms4416 KiB
#include "secret.h" #include "bits/stdc++.h" using namespace std; #define task "" #define ll long long #define endl '\n' #define fi first #define se second #define vall(a) (a).begin(), (a).end() #define sze(a) (int)a.size() #define pii pair<int, int> #define pll pair<ll, ll> #define ep emplace_back #define pb push_back #define pf push_front const ll mod = 1e9 + 7; const int N = 2005 + 5; const ll oo = 1e18; bool START; ll cur[N][15], a[N], n, bit[N]; void dnc(int l, int r, int depth) { if (l == r) return; int mid = (l + r) >> 1; cur[mid][depth] = a[mid]; for (int i = mid - 1; i >= l; --i) cur[i][depth] = Secret(cur[i + 1][depth], a[i]); cur[mid + 1][depth] = a[mid + 1]; for (int i = mid + 2; i <= r; ++i) cur[i][depth] = Secret(cur[i - 1][depth], a[i]); for (int i = mid + 1; i <= r; ++i) bit[i] |= (1 << depth); dnc(l, mid, depth + 1); dnc(mid + 1, r, depth + 1); } void Init(int N, int A[]) { n = N; for (int i = 0; i < n; ++i) a[i] = A[i]; dnc(0, n - 1, 0); } int Query(int L, int R) { int depth = __builtin_ctz(bit[L] ^ bit[R]); int ans = Secret(cur[L][depth], cur[R][depth]); return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...