Submission #54501

#TimeUsernameProblemLanguageResultExecution timeMemory
54501ikura355Secret (JOI14_secret)C++14
100 / 100
641 ms9676 KiB
#include "secret.h" #include<bits/stdc++.h> using namespace std; const int maxn = 1e3 + 5; int n; int a[maxn]; int rec[maxn][maxn]; void prep(int l, int r) { if(l==r) return ; int mid = (l+r)/2; rec[mid][mid] = a[mid]; for(int i=mid-1;i>=l;i--) rec[i][mid] = Secret(a[i], rec[i+1][mid]); rec[mid+1][mid+1] = a[mid+1]; for(int i=mid+2;i<=r;i++) rec[mid+1][i] = Secret(rec[mid+1][i-1], a[i]); prep(l,mid); prep(mid+1,r); } void Init(int N, int A[]) { n = N; for(int i=1;i<=n;i++) a[i] = A[i-1]; for(int i=1;i<=n;i++) { for(int j=1;j<=n;j++) { rec[i][j] = -1; } } prep(1,n); } int Query(int L, int R) { L++; R++; if(rec[L][R]!=-1) return rec[L][R]; for(int i=L;i<R;i++) { if(rec[L][i]!=-1 && rec[i+1][R]!=-1) { return Secret(rec[L][i], rec[i+1][R]); } } }

Compilation message (stderr)

secret.cpp: In function 'int Query(int, int)':
secret.cpp:40:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
#Verdict Execution timeMemoryGrader output
Fetching results...