# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
930625 | oblantis | 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.
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define pb push_back
#define ss second
#define ff first
#define vt vector
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int inf = 1e9;
const int mod = 1e9+7;
const int maxn = 1e6 + 1;
//int secret_count;
map<pii, int> sh;
//int Secret(int X, int Y) {
//++secret_count;
//return (X + 2 * (Y / 2));
}
void go(int l, int r){
if(l + 2 >= r)return;
int mid = l + (r - l) / 2;
for(int i = mid - 2; i >= l; i--){
sh[{i, mid - 1}] = Secret(sh[{i, i}], sh[{i + 1, mid - 1}]);
}
for(int i = mid + 1; i <= r; i++){
sh[{mid, i}] = Secret(sh[{mid, i - 1}], sh[{i, i}]);
}
go(l, mid);
go(mid, r);
}
void Init(int n, int a[]) {
for(int i = 0; i < n; i++){
sh[{i, i}] = a[i];
}
go(0, n);
}
int Query(int l, int r) {
if(sh.find({l, r}) != sh.end())return sh[{l, r}];
for(int j = l; j < r; j++){
if(sh.find({l, j}) != sh.end() && sh.find({j + 1, r}) != sh.end()){
return Secret(sh[{l, j}], sh[{j + 1, r}]);
}
}
return 0;
}
//int main(){
//int n;
//cin >> n;
//int a[n];
//for(int i = 0; i < n; i++){
//cin >> a[i];
//}
//Init(n, a);
//int q;
//cin >> q;
//while(q--){
//int l, r;
//cin >> l >> r;
//cout << Query(l, r) << '\n';
//}
//return 0;
//}