Submission #475835

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

using namespace std;
const int N = 2e5 + 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];
    else {
        int bit = __builtin_ctz(mask[l] ^ mask[r]);
        return Secret(f[bit][l], f[bit][r]);
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 137 ms 2388 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 268854015.
2 Incorrect 139 ms 2484 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 311474560.
3 Incorrect 134 ms 2360 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 353554500.
4 Incorrect 507 ms 4360 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 343081568.
5 Incorrect 503 ms 4336 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 957013316.
6 Incorrect 511 ms 4416 KB Wrong Answer: Query(200, 208) - expected : 277813445, actual : 154975445.
7 Incorrect 506 ms 4340 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 675449873.
8 Incorrect 514 ms 4268 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 273091792.
9 Incorrect 515 ms 4372 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 827853577.
10 Incorrect 502 ms 4420 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 337854787.