#include "secret.h"
#include<bits/stdc++.h>
using namespace std;
int x[1005][1005],a[1005],n;
void solve(int l,int r) {
if(l==r) return;
int mid = (l+r)/2;
x[mid][mid] = a[mid];
for(int i=mid-1;i>=l;i--) {
x[i][mid] = Secret(a[i],x[i+1][mid]);
}
x[mid+1][mid+1]=a[mid+1];
for(int i=mid+2;i<=r;i++) {
x[mid+1][i] = Secret(x[mid+1][i-1],a[i]);
}
solve(l,mid);
solve(mid+1,r);
}
void Init(int m, int A[]) {
Secret(0, 1000000000);
n = m;
for(int i = n; i>0; i--) {
a[i] = A[i-1];
}
solve(1,n);
}
int Query(int L, int R) { //cout<<"++";cout<<"++";
L++; R++;
if(L == R) return a[L];
int l = 1, r = n;
while(true) {
int mid = (l+r)/2;
if(l<=mid && R==mid) return x[L][mid];
if(L==mid+1 && R>mid) return x[mid+1][R];
if(R<=mid) {
r = mid - 1;
continue;
}
if(L>mid) {
l = mid ;
continue;
}
// cout<<L<<" "<<mid<<" "<<x[L][mid]<<" "<<a[R]<<endl;
return Secret(x[L][mid],x[mid+1][R]);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
140 ms |
4348 KB |
Wrong Answer: Query(222, 254) - expected : 34031541, actual : 38994019. |
2 |
Incorrect |
138 ms |
4352 KB |
Wrong Answer: Query(262, 306) - expected : 456068129, actual : 0. |
3 |
Incorrect |
159 ms |
4292 KB |
Wrong Answer: Query(334, 369) - expected : 363022362, actual : 536870912. |
4 |
Incorrect |
536 ms |
8176 KB |
Wrong Answer: Query(384, 458) - expected : 896057572, actual : 536870912. |
5 |
Incorrect |
547 ms |
8116 KB |
Wrong Answer: Query(263, 292) - expected : 653448456, actual : 536870912. |
6 |
Incorrect |
534 ms |
8240 KB |
Wrong Answer: Query(738, 741) - expected : 983692994, actual : 950174288. |
7 |
Correct |
529 ms |
8160 KB |
Output is correct - number of calls to Secret by Init = 7979, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
525 ms |
8132 KB |
Output is correct - number of calls to Secret by Init = 7979, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
529 ms |
8196 KB |
Output is correct - number of calls to Secret by Init = 7979, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
572 ms |
8260 KB |
Output is correct - number of calls to Secret by Init = 7979, maximum number of calls to Secret by Query = 1 |