Submission #1292337

#TimeUsernameProblemLanguageResultExecution timeMemory
1292337mohammadyaySecret (JOI14_secret)C++20
100 / 100
344 ms8332 KiB
#include <bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define ordered_set tree<ll, null_type, less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> #define endl '\n' using ll = long long; #define pb push_back #define pF first #define pS second #define SP <<' '<< const ll mod7 = 1e9+7, mod9= 998244353; const ll MAX_N = 100000; //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int Secret(int X, int Y); int n, *a; struct divcon_SRQ { int s[1123][1123]; void rec(int l, int r, int f) { int sz = r-l+1, firstp = l+(sz+1)/2, secp = l+(sz-1)/2; if (sz == 1) { s[l][f] = a[l]; return; } s[firstp][f] = a[firstp]; for (int i = firstp+1; i <= r; i++) { s[i][f] = Secret(s[i-1][f], a[i]); } s[secp][f] = a[secp]; for (int i = secp-1; i >= l; i--) { s[i][f] = Secret(a[i], s[i+1][f]); } rec(l, secp, f+1); rec(firstp, r, f+1); } void init() { rec(0, n-1, 0); } int query(int f, int l, int r, int ql, int qr) { int sz = r-l+1, firstp = l+(sz+1)/2, secp = l+(sz-1)/2; if (sz == 1) return s[ql][f]; if (qr <= secp) return query(f+1, l, secp, ql, qr); if (ql >= firstp) return query(f+1, firstp, r, ql, qr); return Secret(s[ql][f], s[qr][f]); } }; divcon_SRQ datas; void Init(int N, int A[]) { n = N; a = A; datas.init(); } int Query(int L, int R) { return datas.query(0, 0, n-1, L, R); } /** int main() { ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); } */
#Verdict Execution timeMemoryGrader output
Fetching results...