답안 #475834

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
475834 2021-09-24T08:07:45 Z Shin 비밀 (JOI14_secret) C++14
0 / 100
519 ms 4548 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 Secret(a[l], a[r]);
    else {
        int bit = __builtin_ctz(mask[l] ^ mask[r]);
        return Secret(f[bit][l], f[bit][r]);
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 137 ms 2364 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 268854015.
2 Incorrect 136 ms 2404 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 311474560.
3 Incorrect 138 ms 2464 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 353554500.
4 Incorrect 508 ms 4412 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 343081568.
5 Incorrect 507 ms 4472 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 957013316.
6 Incorrect 504 ms 4320 KB Wrong Answer: Query(915, 915) - expected : 282904741, actual : 31281100.
7 Incorrect 505 ms 4444 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 675449873.
8 Incorrect 511 ms 4360 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 273091792.
9 Incorrect 519 ms 4360 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 827853577.
10 Incorrect 516 ms 4548 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 337854787.