#include<bits/stdc++.h>
#include "secret.h"
using namespace std;
#define fi first
#define se second
#define pb push_back
#define ins insert
#define er erase
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;
//const int oo = 1e18 + 7, mod = 1e9 + 7;
int n, x, y, a[1005], ans[1005][1005], answer, c[1005];
void build(int l, int r){
if(r <= (l + 1)) return;
int mid = (l + r) >> 1;
for(int i = mid - 1; i >= l; i--) ans[i][mid] = Secret(ans[i + 1][mid], a[i]);
for(int i = mid + 2; i <= r; i++) ans[mid + 1][i] = Secret(ans[mid + 1][i - 1], a[i]);
build(l, mid);
build(mid + 1, r);
}
void search(int l, int r){
int mid = (l + r) >> 1;
if(x < l || y > r) return;
if(x <= mid && y > mid){
answer = Secret(ans[x][mid], ans[mid + 1][y]);
return;
}
search(l, mid);
search(mid + 1, r);
}
void Init(int N, int A[]){
n = N;
for(int i = 0; i < n; i++) a[i + 1] = A[i];
for(int i = 1; i <= n; i++) ans[i][i] = a[i];
build(1, n);
}
int Query(int X, int Y){
x = X;
y = Y;
x++;
y++;
if(x == y) return a[x];
else if(x == (y - 1)) return Secret(a[x], a[x + 1]);
answer = 0;
search(1, n);
return answer;
}
/*
TEST HERE
INPUT #1
OUTPUT #1
INPUT #2
OUTPUT #2
INPUT #3
OUTPUT #3
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
142 ms |
4472 KB |
Wrong Answer: Query(113, 206) - expected : 536899947, actual : 538256673. |
2 |
Incorrect |
147 ms |
4412 KB |
Wrong Answer: Query(60, 375) - expected : 669221184, actual : 311474560. |
3 |
Incorrect |
144 ms |
4472 KB |
Wrong Answer: Query(211, 401) - expected : 674373968, actual : 353554500. |
4 |
Incorrect |
513 ms |
8184 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : 343081568. |
5 |
Incorrect |
499 ms |
8336 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : 957013316. |
6 |
Incorrect |
508 ms |
8184 KB |
Wrong Answer: Query(747, 749) - expected : 244228265, actual : 935077363. |
7 |
Incorrect |
502 ms |
8312 KB |
Wrong Answer: Query(84, 976) - expected : 742463504, actual : 675449873. |
8 |
Incorrect |
512 ms |
8312 KB |
Wrong Answer: Query(58, 987) - expected : 20022464, actual : 273091792. |
9 |
Incorrect |
502 ms |
8312 KB |
Wrong Answer: Query(33, 967) - expected : 676869696, actual : 827853577. |
10 |
Incorrect |
503 ms |
8332 KB |
Wrong Answer: Query(116, 961) - expected : 68487362, actual : 337854787. |