# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
859677 | iskhakkutbilim | Secret (JOI14_secret) | C++17 | 636 ms | 8288 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"
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9;
//int Secret(int a, int b){
// return min(a / 2 + b, mod);
//}
int range[1000][1000];
vector<int> a;
int n, ask;
void rec(int l, int r){
if(l > r) return;
if(l == r){
range[l][r] = a[l];
return;
}
if(r-l == 1){
range[l][r] = Secret(a[l], a[l + 1]);
ask++;
return;
}
int mid = (l + r) >> 1;
int oper = a[mid];
range[mid][mid] = oper;
for(int i = mid+1; i <= r; i++){
oper = Secret(oper, a[i]);
range[mid][i] = oper;
}
oper = a[mid-1];
for(int i = mid-1; i >= l; i--){
if(i != mid-1) oper = Secret(oper, a[i]);
for(int j = mid; j <= r; j++){
range[i][j] = Secret(oper, range[mid][j]);
}
}
rec(l, mid);
rec(mid+1, r);
}
void Init(int N, int A[]){
// Secret(0, 1000000000);
cin >> N;
n = N;
for(int i = 0;i < N; i++) a.push_back(A[i]);
rec(0, n-1);
// cout << "Number of calling Secret is " << ask << '\n';
}
int Query(int l, int r){
return range[l][r];
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |