#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <utility>
#include <cmath>
#include <numeric>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x) x.begin(), x.end()
const int M = 1007;
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
#include "secret.h"
int n, sum[M][M], a[M];
void solve(int l, int r)
{
if(l >= r) return;
int mid = (l + r) / 2;
sum[mid][mid] = a[mid];
sum[mid + 1][mid + 1] = a[mid + 1];
for(int i = mid - 1; i >= l; --i) sum[i][mid] = Secret(a[i], sum[i + 1][mid]);
for(int i = mid + 2; i <= r; ++i) sum[mid + 1][i] = Secret(sum[mid + 1][i - 1], a[i]);
solve(l, mid);
solve(mid + 1, r);
return;
}
int get(int st, int en, int l, int r)
{
int mid = (l + r) / 2;
if(en > mid && l <= mid) return Secret(sum[st][mid], sum[mid + 1][en]);
if(en <= mid) return get(st, en, l, mid);
return get(st, en, mid + 1, r);
}
void Init(int N, int A[])
{
n = N;
for(int i = 1; i <= n; ++i) a[i] = A[i - 1];
solve(1, n);
return;
}
int Query(int l, int r)
{
++l; ++r;
if(l == r) return a[l];
return get(l, r, 1, n);
}
// Don't forget special cases. (n = 1?)
// Look for the constraints. (Runtime array? overflow?)
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
113 ms |
4352 KB |
Wrong Answer: Query(222, 254) - expected : 34031541, actual : 576149945. |
2 |
Incorrect |
113 ms |
4452 KB |
Wrong Answer: Query(236, 238) - expected : 173116186, actual : 805962208. |
3 |
Incorrect |
113 ms |
4428 KB |
Wrong Answer: Query(334, 369) - expected : 363022362, actual : 547672410. |
4 |
Incorrect |
420 ms |
8388 KB |
Wrong Answer: Query(384, 458) - expected : 896057572, actual : 323666462. |
5 |
Incorrect |
417 ms |
8252 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : 212882718. |
6 |
Incorrect |
420 ms |
8408 KB |
Wrong Answer: Query(738, 741) - expected : 983692994, actual : 423176097. |
7 |
Correct |
430 ms |
8260 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
441 ms |
8388 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
433 ms |
8248 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
437 ms |
8560 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |