# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
935442 | Baizho | Secret (JOI14_secret) | C++14 | 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 "secret.h"
#ifndef SECRET_H_
#define SECRET_H_
#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<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
// #pragma GCC optimize("Ofast,unroll-loops,fast-math")
// #pragma GCC target("popcnt")
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
#define sz size()
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define pb push_back
const int mod = ll(1e9)+7;
const ll MOD = 998244353;
const long long inf = 5e18;
const int M = 1005;
int Secret(int x, int y);
int val[10][M];
void Init(int n, int a[]) {
for(int i = 0; i < n; i ++) val[0][i] = a[i];
for(int j = 1; j <= 9; j ++) {
for(int i = 0; i + (1 << j) - 1 < n; i ++) {
val[j][i] = Secret(val[j - 1][i], val[j - 1][i + (1 << j - 1)]);
}
}
}
int Query(int l, int r) {
int siz = r - l + 1, res = -1;
for(int j = 9; l <= r && j >= 0; j --) {
if(siz & (1 << j)) {
if(res == -1) res = val[j][l];
else res = Secret(res, val[j][l]);
l += (1 << j);
}
}
return res;
}
#endif /* SECRET_H_ */