Submission #475833

# Submission time Handle Problem Language Result Execution time Memory
475833 2021-09-24T08:06:42 Z Shin Secret (JOI14_secret) C++14
0 / 100
504 ms 4508 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] = f[level][i + 1] + a[i];
    
    f[level][m + 1] = a[m + 1];
    for (int i = m + 2; i <= r; i ++)
        f[level][i] = 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 Secret(a[l], 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 130 ms 2520 KB Wrong Answer [1]
2 Incorrect 131 ms 2452 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 944656280.
3 Incorrect 135 ms 2560 KB Wrong Answer [1]
4 Incorrect 503 ms 4420 KB Wrong Answer [1]
5 Incorrect 502 ms 4364 KB Wrong Answer [1]
6 Incorrect 497 ms 4464 KB Wrong Answer: Query(915, 915) - expected : 282904741, actual : 31281100.
7 Incorrect 503 ms 4472 KB Wrong Answer [1]
8 Incorrect 495 ms 4508 KB Wrong Answer [1]
9 Incorrect 504 ms 4404 KB Wrong Answer [1]
10 Incorrect 501 ms 4496 KB Wrong Answer [1]