Submission #434938

#TimeUsernameProblemLanguageResultExecution timeMemory
434938keta_tsimakuridzeSecret (JOI14_secret)C++14
0 / 100
520 ms8388 KiB
#include "secret.h" #include<bits/stdc++.h> using namespace std; int x[1005][1005],a[1005],n; void solve(int l,int r) { if(l==r) return; int mid = (l+r)/2; for(int i=l;i<mid;i++) { x[i][mid] = Secret(a[i],a[mid]); } x[mid][mid] = a[mid]; for(int i=mid+2;i<=r;i++) { x[mid+1][i] = Secret(a[i],a[mid+1]); } x[mid+1][mid+1]=a[mid+1]; solve(l,mid); solve(mid+1,r); } void Init(int m, int A[]) { //Secret(0, 1000000000); n = m; for(int i = n; i>0; i--) { a[i] = A[i-1]; } solve(1,n); } int Query(int L, int R) { L++; R++; if(L == R) return a[L]; int l = 1, r = n; while(true) { int mid = (l+r)/2; if(R<=mid) { r = mid - 1; continue; } if(L>mid) { l = mid ; continue; } return Secret(x[L][mid],x[mid+1][R]); } }
#Verdict Execution timeMemoryGrader output
Fetching results...