#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#include "secret.h"
const int N = 1000;
int* ar;
vector<int> need[N][N];
void cost(int a, int b)
{
if (a == b)
{
need[a][b].push_back(ar[a]);
return;
} else if (a == b - 1)
{
need[a][a].push_back(ar[a]);
need[b][b].push_back(ar[b]);
need[a][b].push_back(ar[a]);
need[a][b].push_back(ar[b]);
return;
} else if (b - a < 0) return;
int mid = (a + b) / 2;
int cur = ar[mid];
need[mid][mid].push_back(cur);
for (int i = mid - 1; i >= a; i--)
{
cur = Secret(cur, ar[i]);
need[i][mid].push_back(cur);
}
cur = ar[mid + 1];
need[mid + 1][mid + 1].push_back(cur);
for (int i = mid + 2; i <= b; i++)
{
cur = Secret(cur, ar[i]);
need[mid + 1][i].push_back(cur);
}
for (int i = mid; i >= a; i--)
{
for (int j = mid + 1; j <= b; j++)
{
need[i][j].push_back(need[i][mid][0]);
need[i][j].push_back(need[mid + 1][j][0]);
}
}
cost(a, mid - 1);
cost(mid + 1, b);
}
/*
int main()
{
} */
void Init(int n, int A[])
{
ar = A;
cost(0, n - 1);
}
int Query(int l, int r)
{
if (need[l][r].size() == 1) return need[l][r][0];
return Secret(need[l][r][0], need[l][r][1]);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
179 ms |
29956 KB |
Wrong Answer: Query(222, 254) - expected : 34031541, actual : 268854015. |
2 |
Incorrect |
179 ms |
30060 KB |
Wrong Answer: Query(60, 375) - expected : 669221184, actual : 311474560. |
3 |
Incorrect |
159 ms |
30188 KB |
Wrong Answer: Query(211, 401) - expected : 674373968, actual : 353554500. |
4 |
Incorrect |
587 ms |
43476 KB |
Wrong Answer: Query(90, 497) - expected : 397934825, actual : 343081568. |
5 |
Incorrect |
576 ms |
43628 KB |
Wrong Answer: Query(587, 915) - expected : 752404486, actual : 957013316. |
6 |
Incorrect |
560 ms |
43500 KB |
Wrong Answer: Query(738, 741) - expected : 983692994, actual : 850129153. |
7 |
Incorrect |
566 ms |
43720 KB |
Wrong Answer: Query(84, 976) - expected : 742463504, actual : 675449873. |
8 |
Incorrect |
578 ms |
43500 KB |
Wrong Answer: Query(58, 987) - expected : 20022464, actual : 273091792. |
9 |
Incorrect |
599 ms |
43488 KB |
Wrong Answer: Query(33, 967) - expected : 676869696, actual : 827853577. |
10 |
Incorrect |
590 ms |
43420 KB |
Wrong Answer: Query(116, 961) - expected : 68487362, actual : 337854787. |