답안 #1055807

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1055807 2024-08-13T05:41:12 Z trandangquang 비밀 (JOI14_secret) C++14
0 / 100
278 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;
    }

//    cout<<l<<" "<<r<<'\n';
    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]));

//    if(l == 4 && r == 7) {
//        cout << mid << '\n';
//        for(int i:ops[id]) cout << i << " ";
//        cout << '\n';
//    }

    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(R==mid) return ops[id][L-l];
    if(L==mid+1) return ops[id][R-l];
    if(L<=mid && mid+1<=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,4,7,2,5,8,3,6};
//    Init(8, b);
////    cout<<cnt<<'\n';
////    cout<<Query(5,7)<<'\n';
//}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 66 ms 2636 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 268854015.
2 Incorrect 82 ms 2520 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 311474560.
3 Incorrect 66 ms 2500 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 353554500.
4 Incorrect 263 ms 4556 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 343081568.
5 Incorrect 267 ms 4692 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 957013316.
6 Incorrect 269 ms 4484 KB Wrong Answer: Query(200, 208) - expected : 277813445, actual : 154975445.
7 Incorrect 278 ms 4440 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 675449873.
8 Incorrect 255 ms 4436 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 273091792.
9 Incorrect 273 ms 4640 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 827853577.
10 Incorrect 255 ms 4664 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 337854787.