Submission #859679

#TimeUsernameProblemLanguageResultExecution timeMemory
859679iskhakkutbilimSecret (JOI14_secret)C++17
0 / 100
631 ms8292 KiB
#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 + 1]; range[mid + 1][mid + 1] = oper; for(int i = mid+2; i <= r; i++){ oper = Secret(oper, a[i]); range[mid][i] = oper; } oper = a[mid]; range[mid][mid] = oper; for(int i = mid; i >= l; i--){ if(i != mid) 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 timeMemoryGrader output
Fetching results...