Submission #489745

#TimeUsernameProblemLanguageResultExecution timeMemory
489745lukameladzeSecret (JOI14_secret)C++14
6 / 100
1336 ms8388 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 >= 0; i--) { ans[i][mid] = Secret(a[i],ans[i + 1][mid]); //if (i == 1 && mid == 3) cout<<ans[i][mid]<<endl; //cout<<i<<" "<<mid<<" "<<ans[i + 1][mid]<<" "<<a[i]<<" "<<ans[i][mid]<<endl; } for (int i = mid + 2; i < n; i++) { ans[mid + 1][i] = Secret(ans[mid + 1][i - 1], a[i]); //if (mid + 1 == 4 && i == 7) cout<<ans[mid + 1][i]<<endl; //cout<<mid<<" "<<i<<" "<<ans[mid][i]<<endl; } solve(le, mid); solve(mid + 1, ri); } int getans(int le, int ri, int start, int end) { int mid = (le + ri) / 2; //cout<<le<<" "<<ri<<" "<<start<<" "<<endl; if (le <= start && ri >= end) { // cout<<le<<" "<<ri<<" "<<start<<endl; if (end == mid) { return ans[start][mid]; } if (start == mid + 1) { return ans[mid + 1][end]; } if (mid >= start && mid <= end) { //cout<<start<<" "<<mid<<" "<<mid + 1<<" "<<end; // cout<<start<<" "<<mid<<" "<<mid + 1<<" "<<end<<endl; 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:49:1: warning: control reaches end of non-void function [-Wreturn-type]
   49 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...