Submission #578874

#TimeUsernameProblemLanguageResultExecution timeMemory
578874ddy888Secret (JOI14_secret)C++17
0 / 100
484 ms8292 KiB
#include "secret.h" #include <bits/stdc++.h> using namespace std; using ll = long long; #define pb push_back #define fi first #define si second typedef pair<int,int> pi; typedef tuple<int,int,int> ti; void debug_out() {cerr<<endl;} template <typename Head, typename... Tail> void debug_out(Head _H, Tail... _T) {cerr<<" "<<to_string(_H);debug_out(_T...);} #define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__) mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int MAXN = 1010; int n, arr[MAXN]; int t[MAXN][MAXN]; void dnc(int l, int r) { if (l == r) return; int m = (l + r) >> 1; t[m][m] = arr[m]; t[m + 1][m + 1] = arr[m + 1]; for (int i = m - 1; i >= l; --i) if (i <= n) t[i][m] = Secret(arr[i], t[i + 1][m]); for (int i = m + 2; i <= r; ++i) if (i <= n) t[m + 1][i] = Secret(arr[i], t[m + 1][i - 1]); dnc(l, m); dnc(m + 1, r); } void Init(int N, int A[]) { n = N; for (int i = 1; i <= n; ++i) arr[i] = A[i - 1]; dnc(1, n); } int Query(int L, int R) { ++L, ++R; if (L == R) return arr[L]; int l = 1, r = n; while (l != r) { int m = (l + r) >> 1; if (L <= m && r > m) return Secret(t[L][m], t[m + 1][R]); if (L >= m) l = m; else if (R < m) r = m; } return t[l][r]; }
#Verdict Execution timeMemoryGrader output
Fetching results...