//Be Name KHODA
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include "secret.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define pp pop_back
#define lb lower_bound
#define ub upper_bound
#define cl clear
#define bg begin
#define arr(x) array<int , x>
#define endl '\n'
int n;
vector<int> a;
int zam[4001][2][1000] , zaminf[4001];
void buildZam(int l = 0 , int r = n - 1 , int i = 1){
int c = (r + l) >> 1 , res = a[c];
zaminf[i] = c , zam[i][0][c] = a[c];
if(r == l) return;
zam[i][1][c + 1] = a[c + 1];
for(int j = c - 1 ; j >= l ; j--) res = Secret(a[j] , res) , zam[i][0][j] = res;
res = a[c + 1] , zam[i][0][c + 1] = a[c + 1];
for(int j = c + 2 ; j <= r ; j++) res = Secret(res , a[j]) , zam[i][1][j] = res;
if(r > l + 1) buildZam(l , c - 1 , i << 1);
buildZam(c + 1 , r , (i << 1) | 1);
}
int getZam(int l , int r , int i){
if(l <= zaminf[i] and r >= zaminf[i]) return Secret(zam[i][0][l] , zam[i][1][r]);
if(r < zaminf[i]) return getZam(l , r , i << 1);
return getZam(l , r , (i << 1) | 1);
}
void Init(int N , int A[]){
n = N;
for(int i = 0 ; i < n ; i++) a.pb(A[i]);
buildZam();
}
int Query(int L , int R){
return getZam(L , R , 1);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
97 ms |
8808 KB |
Wrong Answer: Query(264, 271) - expected : 675707686, actual : 4619042. |
2 |
Incorrect |
97 ms |
10860 KB |
Wrong Answer: Query(210, 211) - expected : 558550312, actual : 558532904. |
3 |
Incorrect |
96 ms |
12896 KB |
Wrong Answer: Query(130, 131) - expected : 127065177, actual : 93509720. |
4 |
Incorrect |
358 ms |
12840 KB |
Wrong Answer: Query(571, 624) - expected : 309502044, actual : 309493852. |
5 |
Incorrect |
372 ms |
12892 KB |
Wrong Answer: Query(584, 592) - expected : 111053842, actual : 110791698. |
6 |
Incorrect |
355 ms |
12896 KB |
Wrong Answer: Query(915, 915) - expected : 282904741, actual : 278446241. |
7 |
Correct |
360 ms |
12888 KB |
Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
360 ms |
13148 KB |
Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
364 ms |
12892 KB |
Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
362 ms |
12884 KB |
Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1 |