Submission #965102

#TimeUsernameProblemLanguageResultExecution timeMemory
965102EsgeerSecret (JOI14_secret)C++17
100 / 100
413 ms4532 KiB
#include <bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <unistd.h> using namespace __gnu_pbds; template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #ifndef Local #pragma GCC optimize("O3,unroll-loops") #endif //#define int long long #define vi vector<int> #define vvi vector<vi> #define pii pair<int, int> #define vpi vector<pii> #define vvpi vector<vpi> #define vb vector<bool> #define vvb vector<vb> #define endl '\n' #define sp << " " << #define F(i, s, n) for(int i = s; i < (int) n; i++) #define pb push_back #define fi first #define se second #include "secret.h" int mod = 1e9+7; int inf = 1e6; const int N = 1005; int dat[11][N]; int mask[N]; int a[N]; void divi(int l, int r, int layer) { if(l == r) return; int m = (l + r) >> 1; dat[layer][m] = a[m]; for(int i = m-1; i >= l; i--) dat[layer][i] = Secret(a[i], dat[layer][i+1]); dat[layer][m+1] = a[m+1]; for(int i = m+2; i <= r; i++) dat[layer][i] = Secret(dat[layer][i-1], a[i]); for(int i = m+1; i <= r; i++) mask[i] ^= (1 << layer); divi(l, m, layer+1); divi(m+1, r, layer+1); } void Init(int N, int A[]) { F(i, 0, N) a[i] = A[i]; divi(0, N-1, 0); } int Query(int l, int r) { if(l == r) return a[l]; int layer = __builtin_ctz(mask[l] ^ mask[r]); return Secret(dat[layer][l], dat[layer][r]); }
#Verdict Execution timeMemoryGrader output
Fetching results...