답안 #1055696

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1055696 2024-08-13T03:41:42 Z trandangquang 비밀 (JOI14_secret) C++14
0 / 100
272 ms 4692 KB
#include <bits/stdc++.h>
#include "secret.h"

#define FOR(i, a, b) for(int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define eb emplace_back
#define all(a) (a).begin(), (a).end()
using namespace std;

int n, a[1005], cnt;
vector <int> ops[4005];

//int Secret(int X, int Y) {
//    /// program's
//    ++cnt;
//    return X^Y;
//}

void build(int id=1, int l=0, int r=n-1) {
    if(l == r) {
        ops[id] = {a[l]};
        return;
    }

    int mid = (l + r) >> 1;

    ops[id] = {a[mid]};
    FORD(i, mid-1, l) ops[id].eb(Secret(ops[id].back(), a[i]));

    reverse(all(ops[id]));

    ops[id].eb(a[mid+1]);
    FOR(i, mid+2, r) ops[id].eb(Secret(ops[id].back(), a[i]));

    build(id<<1, l, mid);
    build(id<<1|1, mid+1, r);
}

void Init(int N, int A[]) {
    n = N;
    FOR(i, 0, N-1) {
        a[i] = A[i];
    }
    build();
}

int get(int L, int R, int id=1, int l=0, int r=n-1) {
    int mid = (l+r) >> 1;

    if(L <= mid && mid <= R) {
        return Secret(ops[id][L-l], ops[id][R-l]);
    }

    if(R<=mid) return get(L, R, id<<1, l, mid);
    return get(L, R, id<<1|1, mid+1, r);
}

int Query(int L, int R) {
    return get(L, R);
}

//int main() {
//    int b[] = {1,2,3,4};
//    Init(4, b);
//    cout<<cnt<<'\n';
//    cout<<Query(1,2)<<'\n';
//}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 68 ms 2724 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 268854015.
2 Incorrect 67 ms 2644 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 311474560.
3 Incorrect 66 ms 2588 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 353554500.
4 Incorrect 253 ms 4568 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 343081568.
5 Incorrect 253 ms 4492 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 957013316.
6 Incorrect 255 ms 4436 KB Wrong Answer: Query(915, 915) - expected : 282904741, actual : 31281100.
7 Incorrect 253 ms 4688 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 675449873.
8 Incorrect 270 ms 4692 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 273091792.
9 Incorrect 257 ms 4556 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 827853577.
10 Incorrect 272 ms 4436 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 337854787.