Submission #412482

#TimeUsernameProblemLanguageResultExecution timeMemory
412482songcSecret (JOI14_secret)C++14
0 / 100
529 ms4372 KiB
#include "secret.h" int N; int A[1010], T[20][1010]; void dnc(int d, int s, int e){ if (s == e) return; int m=s+e>>1; T[d][m+1] = A[m+1]; for (int i=m+2; i<=e; i++) T[d][i] = Secret(T[d][i-1], A[i]); T[d][m] = A[m]; for (int i=m-1; i>=s; i--) T[d][i] = Secret(A[i], T[d][i+1]); dnc(d+1, s, m), dnc(d+1, m+1, e); } void Init(int _N, int P[]){ N = _N; for (int i=0; i<N; i++) A[i] = P[i]; dnc(0, 0, N-1); } int qry(int d, int s, int e, int ts, int te){ int m=s+e>>1; if (ts <= m && m <= te) return Secret(T[d][ts], T[d][te]); if (te <= m) return qry(d+1, s, m, ts, te); return qry(d+1, m+1, e, ts, te); } int Query(int L, int R){ if (L == R) return A[L]; return qry(0, 0, N-1, L, R); }

Compilation message (stderr)

secret.cpp: In function 'void dnc(int, int, int)':
secret.cpp:8:9: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    8 |  int m=s+e>>1;
      |        ~^~
secret.cpp: In function 'int qry(int, int, int, int, int)':
secret.cpp:23:9: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   23 |  int m=s+e>>1;
      |        ~^~
#Verdict Execution timeMemoryGrader output
Fetching results...