# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1034833 | ethanv13 | Secret (JOI14_secret) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include <secret.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC target("avx")
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#define ll long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
int sps[15][1005];
int l2(int p){
return 31-__builtin_clz(p);
}
void sps(int n,int a[]){
int k=l2(n);
for(int i=0;i<n;++i){
sps[0][i]=a[i];
}
for(int i=1;i<=k;++i){
for(int j=0;j+(1<<i)<=n;++j){
sps[i][j]=secret(sps[i-1][j],sps[i-1][j+(1<<(i-1))]);
}
}
}
void INIT(int N,int a[]){
sps(N,a);
}
int query(int L,int R){
int i = l2(R-L+1);
int minimum = secret(sps[i][L], sps[i][R - (1 << i) + 1]);
return minimum;
}