Submission #1316373

#TimeUsernameProblemLanguageResultExecution timeMemory
1316373blackscreen1Secret (JOI14_secret)C++20
100 / 100
339 ms12208 KiB
#include "secret.h" #include <bits//stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset; #define ll int #define iloop(m, h) for (auto i = m; i != h; i += (m < h ? 1 : -1)) #define jloop(m, h) for (auto j = m; j != h; j += (m < h ? 1 : -1)) #define pll pair<ll, ll> #define INF 1000000000000000 #define MOD1 1000000007 #define MOD2 998244353 #define MOD3 1000000009 ll n, a[1005]; struct node { ll s, e, m; ll pv[1005]; node *l, *r; node (ll S, ll E) { s = S, e = E, m = (S+E)>>1; if (s == e) return; l = new node(s, m); r = new node(m+1, e); pv[m] = a[m]; iloop(m-1, s-1) pv[i] = Secret(a[i], pv[i+1]); pv[m+1] = a[m+1]; iloop(m+2, e+1) pv[i] = Secret(pv[i-1], a[i]); } ll qu(ll S, ll E) { if (E <= m) return l->qu(S, E); if (S > m) return r->qu(S, E); return Secret(pv[S], pv[E]); } } *root; void Init(int N, int A[]) { n = N; iloop(0, n) a[i] = A[i]; root = new node(0, n-1); } int Query(int L, int R) { if (L == R) return a[L]; return root->qu(L, R); }
#Verdict Execution timeMemoryGrader output
Fetching results...