Submission #475836

# Submission time Handle Problem Language Result Execution time Memory
475836 2021-09-24T08:16:31 Z Shin Secret (JOI14_secret) C++14
0 / 100
510 ms 4452 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#include "secret.h"

using namespace std;
const int N = 2e3 + 7;
const int LOG = 20;
const int MOD = 1e9 + 7; // 998244353;
const int INF = 1e9 + 7;
const long long INFLL = 1e18 + 7;

typedef long long ll;
typedef unsigned long long ull;
template <class X, class Y> bool minimize(X &a, Y b) {
    if (a > b) return a = b, true;
    return false;
}
template <class X, class Y> bool maximize(X &a, Y b) {
    if (a < b) return a = b, true;
    return false;
}

int n;
int a[N];
int mask[N];
int f[LOG + 1][N];

void compute(int l, int r, int level) {
    if (l >= r) return;
    
    int m = (l + r) >> 1;
    f[level][m] = a[m];
    for (int i = m - 1; i >= l; i --)
        f[level][i] = Secret(f[level][i + 1], a[i]);
    
    f[level][m + 1] = a[m + 1];
    for (int i = m + 2; i <= r; i ++)
        f[level][i] = Secret(f[level][i - 1], a[i]);

    for (int i = m + 1; i <= r; i ++) mask[i] ^= (1 << level);
    compute(l, m, level + 1);
    compute(m + 1, r, level + 1);
}

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

int Query(int l, int r) {
    l ++; r ++;
    if (l == r) return a[r];
    if (r - l == 1) return Secret(a[l], a[r]);
    int bit = __builtin_ctz(mask[l] ^ mask[r]);
    return Secret(f[bit][l], f[bit][r]);
}
# Verdict Execution time Memory Grader output
1 Incorrect 137 ms 2404 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 268854015.
2 Incorrect 137 ms 2524 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 311474560.
3 Incorrect 136 ms 2372 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 353554500.
4 Incorrect 500 ms 4276 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 343081568.
5 Incorrect 506 ms 4332 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 957013316.
6 Incorrect 501 ms 4276 KB Wrong Answer: Query(200, 208) - expected : 277813445, actual : 154975445.
7 Incorrect 506 ms 4288 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 675449873.
8 Incorrect 509 ms 4368 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 273091792.
9 Incorrect 498 ms 4276 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 827853577.
10 Incorrect 510 ms 4452 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 337854787.