Submission #242401

#TimeUsernameProblemLanguageResultExecution timeMemory
242401AM1648Secret (JOI14_secret)C++17
0 / 100
20082 ms4600 KiB
/* be name khoda */ // #define long_enable #include <iostream> #include <algorithm> #include <cstring> #include <numeric> #include <vector> #include <fstream> #include <set> #include <map> #include "secret.h" using namespace std; #ifdef long_enable typedef long long int ll; #else typedef int ll; #endif typedef pair<ll, ll> pii; typedef pair<pii, ll> ppi; typedef pair<ll, pii> pip; typedef vector<ll> vi; typedef vector<pii> vpii; #define forifrom(i, s, n) for (ll i = s; i < n; ++i) #define forirto(i, n, e) for (ll i = (n) - 1; i >= e; --i) #define fori(i, n) forifrom (i, 0, n) #define forir(i, n) forirto (i, n, 0) #define F first #define S second #define pb push_back #define eb emplace_back #define all(x) (x).begin(), (x).end() #define smin(a, b) a = min(a, (b)) #define smax(a, b) a = max(a, (b)) #define debug(x) cout << #x << " -> " << (x) << endl #define debug2(x, y) cout << #x << ' ' << #y << " -> " << (x) << ' ' << (y) << endl #define debug3(x, y, z) cout << #x << ' ' << #y << ' ' << #z << " -> " << (x) << ' ' << (y) << ' ' << (z) << endl #define debug4(x, y, z, t) cout << #x << ' ' << #y << ' ' << #z << ' ' << #t << " -> " << (x) << ' ' << (y) << ' ' << (z) << ' ' << (t) << endl #define debuga(x, n) cout << #x << " -> "; fori (i1_da, n) { cout << (x)[i1_da] << ' '; } cout << endl #define debugaa(x, n, m) cout << #x << " ->\n"; fori (i1_daa, n) { fori (i2_daa, m) { cout << (x)[i1_daa][i2_daa] << ' '; } cout << '\n'; } cout << endl const ll MOD = 1000000007; const ll INF = 2000000000; const long long BIG = 1446803456761533460LL; #define XL (x << 1) #define XR (XL | 1) #define MD ((l + r) >> 1) #define Add(a, b) a = ((a) + (b)) % MOD #define Mul(a, b) a = (1LL * (a) * (b)) % MOD // ----------------------------------------------------------------------- const ll maxn = 1002; const ll maxnlg = 10; ll n, A[maxn]; ll pre[maxnlg][maxn]; void calc(ll h, ll l, ll r) { if (r - l <= 2) return; ll mid = (l + r) / 2; pre[h][mid] = A[mid], pre[h][mid - 1] = A[mid - 1]; forifrom (i, mid + 1, r) pre[h][i] = Secret(pre[h][i - 1], A[i]); forir (i, mid - 1) pre[h][i] = Secret(pre[h][i + 1], A[i]); calc(h + 1, l, mid); calc(h + 1, mid, r); } ll find(ll L, ll R, ll h = 0, ll l = 0, ll r = n) { ll mid = (l + r) / 2; if (L >= mid) return find(L, R, h + 1, l, mid); if (R <= mid) return find(L, R, h + 1, mid, r); else return Secret(pre[h][L], pre[h][R - 1]); } void Init(ll N, ll I[]) { n = N; fori (i, n) A[i] = I[i]; calc(0, 0, n); } ll Query(ll l, ll r) { ++r; if (r - l == 1) return A[l]; else if (r - l == 2) return Secret(A[l], A[l + 1]); else return find(l, r); }
#Verdict Execution timeMemoryGrader output
Fetching results...