Submission #949753

#TimeUsernameProblemLanguageResultExecution timeMemory
949753Trisanu_DasSecret (JOI14_secret)C++17
0 / 100
381 ms8532 KiB
#include <bits/stdc++.h> #include "secret.h" int memo[1000][1000], n; void build(int l, int r, int A[]){ int m = (l + r) / 2; memo[m][m] = A[m]; memo[m + 1][m + 1] = A[m + 1]; for(int i = m + 2; i <= r; i++) memo[m + 1][i] = Secret(memo[m + 1][i - 1], A[i]); for(int i = m - 1; i >= l; i--) memo[m][i] = Secret(memo[m][i + 1], A[i]); if(l < m) build(l, m, A); if(m + 1 < r) build(m + 1, r, A); } void Init(int N, int A[]){ n = N; build(0, n - 1, A); } int Query(int L, int R){ int l = 0, r = n - 1; while(l < r){ int m = (l + r) / 2; if(L <= m && m < R) return Secret(memo[m][L], memo[m + 1][R]); else if(m == R) return memo[m][L]; else if(m < L) l = m + 1; else r = m; } return memo[l][l]; }
#Verdict Execution timeMemoryGrader output
Fetching results...