Submission #985765

# Submission time Handle Problem Language Result Execution time Memory
985765 2024-05-18T17:15:21 Z tfgs Secret (JOI14_secret) C++17
0 / 100
398 ms 8372 KB
#include "secret.h"
#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL
#include "algo/debug.h"
#endif

#define f first
#define s second
template<class T> using V = vector<T>; 
using vi = V<int>;
using vb = V<bool>;
using vs = V<string>;

#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x) 
#define pb push_back
#define lb lower_bound
#define ub upper_bound
template<class T> int lwb(V<T>& a, const T& b) { return lb(all(a),b)-bg(a); }
template<class T> int upb(V<T>& a, const T& b) { return ub(all(a),b)-bg(a); }

const int max_n = 1000;
int range[max_n+1][max_n+1];

void precalc(int l, int r) {
    if (l == r-1) return;
    int m = (l+r)/2;
    for (int i = m-1; i >= l; i--) if (range[i][m] == -1) {
        range[i][m] = Secret(range[i+1][m], range[i][i+1]);
    }
    for (int i = m+1; i <= r; i++) if (range[m][i] == -1) {
        range[m][i] = Secret(range[m][i-1], range[i-1][i]);
    }
    precalc(l, m);
    precalc(m, r);
}

void Init(int N, int A[]) {
    memset(range, -1, sizeof range);
    for (int i = 0; i < N; i++) range[i][i+1] = A[i];
    precalc(0, N);
}

int Query(int L, int R) {
    for (int i = L+1; i <= R; i++) {
        if (range[L][i] != -1 && range[i][R+1] != -1)
            return Secret(range[L][i], range[i][R+1]);
    }
    return range[L][R+1];
}
# Verdict Execution time Memory Grader output
1 Incorrect 102 ms 8276 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 319912893.
2 Incorrect 111 ms 8276 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 311474560.
3 Incorrect 101 ms 8356 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 162768982.
4 Incorrect 372 ms 8372 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 858309235.
5 Incorrect 373 ms 8272 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 957013316.
6 Incorrect 398 ms 8368 KB Wrong Answer: Query(738, 741) - expected : 983692994, actual : 61461050.
7 Incorrect 371 ms 8336 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 675449873.
8 Incorrect 373 ms 8360 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 273091792.
9 Incorrect 374 ms 8360 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 827853577.
10 Incorrect 374 ms 8272 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 337854787.