Submission #483302

# Submission time Handle Problem Language Result Execution time Memory
483302 2021-10-28T14:59:12 Z Alexandruabcde Secret (JOI14_secret) C++14
0 / 100
20000 ms 8200 KB
#include <bits/stdc++.h>
#include "secret.h"

using namespace std;

typedef long long LL;
constexpr int NMAX = 1005;

int n;
int V[NMAX];
int ans[NMAX][NMAX];

void Precalculare (int Left, int Right) {
    if (Left >= Right) return;

    int mij = (Left + Right) / 2;
    ans[mij][mij] = V[mij];

    for (int i = mij-1; i >= Left; -- i )
        ans[i][mij] = Secret(V[i], ans[i+1][mij]);

    ans[mij+1][mij+1] = V[mij+1];
    for (int i = mij+2; i <= Right; ++ i )
        ans[mij+1][i] = Secret(ans[mij+1][i-1], V[i]);

    Precalculare(Left, mij);
    Precalculare(mij+1, Right);
}

void Init (int N, int A[]) {
    n = N;
    for (int i = 1; i <= N; ++ i )
        V[i] = A[i-1];

    Precalculare(1, N);
}

int Answer (int st, int dr, int qa, int qb) {
    int mij = (st + dr) / 2;

    if (qa <= mij && mij < qb)
        return Secret(ans[qa][mij], ans[mij+1][qb]);

    if (qb <= mij)
        return Answer(st, mij, qa, qb);

    return Answer(mij+1, dr, qa, qb);
}

int Query(int L, int R) {
    return Answer(1, n, L+1, R+1);
}
# Verdict Execution time Memory Grader output
1 Execution timed out 20058 ms 4324 KB Time limit exceeded
2 Execution timed out 20084 ms 4508 KB Time limit exceeded
3 Execution timed out 20081 ms 4372 KB Time limit exceeded
4 Execution timed out 20071 ms 8148 KB Time limit exceeded
5 Execution timed out 20096 ms 8168 KB Time limit exceeded
6 Execution timed out 20080 ms 8120 KB Time limit exceeded
7 Correct 445 ms 8200 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
8 Correct 449 ms 8112 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
9 Correct 431 ms 8132 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
10 Correct 428 ms 8132 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1