Submission #489746

#TimeUsernameProblemLanguageResultExecution timeMemory
489746lukameladzeSecret (JOI14_secret)C++14
100 / 100
443 ms8220 KiB
# include <bits/stdc++.h> # include <secret.h> #define f first #define s second #define pb push_back using namespace std; const int M = 1005; int a[M],ans[M][M],n; /*int Secret(int a, int b) { return min(1000000000, a + 2*(b/2)); }*/ void solve(int le, int ri) { if (le == ri) return ; int mid = (le + ri) / 2; // cout<<le<<" "<<ri<<endl; for (int i = mid - 1; i >= le; i--) { ans[i][mid] = Secret(a[i],ans[i + 1][mid]); } for (int i = mid + 2; i <= ri; i++) { ans[mid + 1][i] = Secret(ans[mid + 1][i - 1], a[i]); } solve(le, mid); solve(mid + 1, ri); } int getans(int le, int ri, int start, int end) { int mid = (le + ri) / 2; if (le <= start && ri >= end) { if (end == mid) { return ans[start][mid]; } if (start == mid + 1) { return ans[mid + 1][end]; } if (mid >= start && mid <= end) { return Secret(ans[start][mid], ans[mid + 1][end]); } if (mid >= end) { return getans(le,mid,start,end); } else return getans(mid + 1, ri, start,end); } } void Init(int N, int A[]) { n = N; for (int i = 0; i < n; i++) { a[i] = A[i]; ans[i][i] = a[i]; } solve(0,n - 1); } int Query(int L,int R) { return getans(0,n-1,L,R); }

Compilation message (stderr)

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