#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define int long long
#define F first
#define S second
//#define endl '\n'
#define INT INT_MAX
int const M = 1e3 + 10 , N = 3e6 , lg = 25 , mod = 1e9 + 7;
int dx[] = {0 , 0 , -1 , 1 , 1 , 1 , -1 , -1};
int dy[] = {1 , -1 , 0 , 0 , 1 , -1 , 1 , -1};
int T , n , j , ans[M][M] , a[M] , Q , l , r , Size , s[M];
/*
inline ll Secret(int x , int y) {
//cout << x << " " << y << endl;
int res;
res = x + y;
return res;
}
*/
void Go(int x = 1 , int lx = 1 , int rx = Size) {
if(lx == rx) {
ans[lx][rx] = s[lx];
return;
}
int mid = (lx + rx) / 2;
int a = mid , b = mid + 1;
ans[b][b] = s[b];
for(int i = b + 1 ; i <= rx ; ++i) ans[b][i] = Secret(ans[b][i - 1] , s[i]);
ans[a][a] = s[a];
if(a <= n) for(int i = a - 1 ; i >= lx ; --i) ans[i][a] = Secret(ans[i + 1][a] , s[i]);
Go(2 * x , lx , mid);
Go(2 * x + 1 , mid + 1 , rx);
}
int Get(int l , int r , int x = 1 , int lx = 1 , int rx = Size) {
int mid = (lx + rx) / 2;
if(lx == rx) return s[lx];
if(mid >= l && mid <= r) return Secret(ans[l][mid] , ans[mid + 1][r]);
if(l > mid) return Get(l , r , 2 * x + 1 , mid + 1 , rx);
else return Get(l , r , 2 * x, lx , mid);
}
void Init(int sz , int ar[]) {
n = sz;
for(int i = n ; i >= 1 ; --i) s[i] = ar[i - 1];
Size = (1 << 10);
Go();
}
int Query(int l , int r) {
++l , ++r;
return Get(l , r);
}
/*
main() {
ios_base::sync_with_stdio(false);cin.tie(nullptr);
return 0;
}
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
122 ms |
12700 KB |
Execution killed with signal 11 |
2 |
Runtime error |
140 ms |
12700 KB |
Execution killed with signal 11 |
3 |
Runtime error |
122 ms |
12712 KB |
Execution killed with signal 11 |
4 |
Runtime error |
446 ms |
16664 KB |
Execution killed with signal 11 |
5 |
Runtime error |
455 ms |
16616 KB |
Execution killed with signal 11 |
6 |
Runtime error |
461 ms |
16600 KB |
Execution killed with signal 11 |
7 |
Runtime error |
445 ms |
16496 KB |
Execution killed with signal 11 |
8 |
Runtime error |
471 ms |
16528 KB |
Execution killed with signal 11 |
9 |
Runtime error |
449 ms |
16580 KB |
Execution killed with signal 11 |
10 |
Runtime error |
456 ms |
16592 KB |
Execution killed with signal 11 |