#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(ar[i], cur);
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 + 2, b);
}
/*
int main()
{
} */
void Init(int n, int A[])
{
ar = A;
cost(0, n - 1);
}
int Query(int l, int r)
{
int actual = ar[l];
for (int i = l + 1; i <= r; i++) actual = Secret(actual, ar[i]);
if (need[l][r].size() == 1) return need[l][r][0];
int cur = Secret(need[l][r][0], need[l][r][1]);
return cur;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
1825 ms |
30060 KB |
Output isn't correct - number of calls to Secret by Init = 3084, maximum number of calls to Secret by Query = 507 |
2 |
Partially correct |
1802 ms |
30072 KB |
Output isn't correct - number of calls to Secret by Init = 3092, maximum number of calls to Secret by Query = 509 |
3 |
Partially correct |
1828 ms |
30060 KB |
Output isn't correct - number of calls to Secret by Init = 3100, maximum number of calls to Secret by Query = 506 |
4 |
Partially correct |
3765 ms |
43548 KB |
Output isn't correct - number of calls to Secret by Init = 6988, maximum number of calls to Secret by Query = 998 |
5 |
Partially correct |
3813 ms |
43560 KB |
Output isn't correct - number of calls to Secret by Init = 6996, maximum number of calls to Secret by Query = 993 |
6 |
Partially correct |
601 ms |
43500 KB |
Output is partially correct - number of calls to Secret by Init = 6996, maximum number of calls to Secret by Query = 11 |
7 |
Partially correct |
9385 ms |
43520 KB |
Output isn't correct - number of calls to Secret by Init = 6996, maximum number of calls to Secret by Query = 1000 |
8 |
Partially correct |
8982 ms |
43520 KB |
Output isn't correct - number of calls to Secret by Init = 6996, maximum number of calls to Secret by Query = 1000 |
9 |
Partially correct |
9029 ms |
43520 KB |
Output isn't correct - number of calls to Secret by Init = 6996, maximum number of calls to Secret by Query = 999 |
10 |
Partially correct |
8991 ms |
43536 KB |
Output isn't correct - number of calls to Secret by Init = 6996, maximum number of calls to Secret by Query = 1000 |