# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
366604 | idk321 | Secret (JOI14_secret) | C++11 | 561 ms | 43756 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#include "secret.h"
const int N = 1000;
int val[N][9];
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;
}
int mid = (a + b) / 2;
vector<int> l(N);
l[mid] = ar[mid];
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]);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |