Submission #707990

#TimeUsernameProblemLanguageResultExecution timeMemory
707990Dan4LifeSecret (JOI14_secret)C++17
0 / 100
449 ms8556 KiB
#include "secret.h" #include <bits/stdc++.h> using namespace std; const int mxN = 1010; int n, ans[mxN][mxN]; void dnc(int l, int r){ if(l==r) return; int m = (l+r)/2; for(int i = m-1; i>=l; i--) ans[i][m] = Secret(ans[i+1][m],ans[i][i]); for(int i = m+1; i<=r; i++) ans[i][m] = Secret(ans[i][i],ans[i-1][i]); dnc(l,m), dnc(m+1,r); } int dnc2(int l, int r, int L, int R){ if(l==r) return ans[l][r]; int m = (l+r)/2; if(L<=m and m<=R) return Secret(ans[l][m],ans[m+1][r]); if(m<L) return dnc2(l,m,L,R); return dnc2(m+1,r,L,R); } void Init(int N, int A[]) { for(int i = 0; i < N; i++) ans[i][i]=A[i]; dnc(1,N); n=N; } int Query(int L, int R) { if(L==R) return ans[L][L]; return dnc2(1,n,L,R); }
#Verdict Execution timeMemoryGrader output
Fetching results...