#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
int seg[4000],n,arr[1000],cnt=0;
void update(int idx=1,int l=0,int r = n-1){
if(l == r){
seg[idx] = arr[l];
return;
}
int mid = (l+r)>>1;
update(idx<<1,mid+1,r);
update(idx<<1|1,l,mid);
seg[idx] = Secret(seg[idx<<1|1], seg[idx<<1]);
//cout<<l<<' '<<r<<' '<<seg[idx<<1]<<' '<<seg[idx<<1|1]<<' '<<seg[idx]<<endl;
}
map<pair<int,int>,int>mp;
int query(int L,int R,int idx=1,int l=0,int r=n-1){
if(l >= L && r <= R)return seg[idx];
if(r < L || l > R)return -1;
int mid = (l+r)>>1;
int first = query(L,R,idx<<1,mid+1,r);
int second = query(L,R,idx<<1|1,l,mid);
if(first != -1 && second != -1){
if(mp.find({second,first}) == mp.end())
return mp[{second,first}] = Secret(second,first);
else return mp[{second,first}];
}
else if(first != -1)
return first;
else if(second != -1)
return second;
else return -1;
}
int dp[1000][1000];
void Init(int N,int A[]){
n = N;
for(int i=0;i<n;i++)arr[i] = A[i];
update();
for(int i=0;i<n;i++){
for(int j=i;j<n;j++){
dp[i][j] = query(i,j);
}
}
}
int Query(int l,int r){
return dp[l][r];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
340 ms |
12492 KB |
Output isn't correct - number of calls to Secret by Init = 130305, maximum number of calls to Secret by Query = 0 |
2 |
Partially correct |
400 ms |
12548 KB |
Output isn't correct - number of calls to Secret by Init = 130816, maximum number of calls to Secret by Query = 0 |
3 |
Partially correct |
360 ms |
12512 KB |
Output isn't correct - number of calls to Secret by Init = 131328, maximum number of calls to Secret by Query = 0 |
4 |
Partially correct |
1465 ms |
39464 KB |
Output isn't correct - number of calls to Secret by Init = 498501, maximum number of calls to Secret by Query = 0 |
5 |
Partially correct |
1467 ms |
39348 KB |
Output isn't correct - number of calls to Secret by Init = 499500, maximum number of calls to Secret by Query = 0 |
6 |
Partially correct |
1452 ms |
39404 KB |
Output isn't correct - number of calls to Secret by Init = 499500, maximum number of calls to Secret by Query = 0 |
7 |
Partially correct |
1465 ms |
39396 KB |
Output isn't correct - number of calls to Secret by Init = 499500, maximum number of calls to Secret by Query = 0 |
8 |
Partially correct |
1533 ms |
39388 KB |
Output isn't correct - number of calls to Secret by Init = 499500, maximum number of calls to Secret by Query = 0 |
9 |
Partially correct |
1466 ms |
39304 KB |
Output isn't correct - number of calls to Secret by Init = 499500, maximum number of calls to Secret by Query = 0 |
10 |
Partially correct |
1440 ms |
39388 KB |
Output isn't correct - number of calls to Secret by Init = 499500, maximum number of calls to Secret by Query = 0 |