답안 #639154

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
639154 2022-09-08T18:18:18 Z phoenix 비밀 (JOI14_secret) C++17
0 / 100
434 ms 4356 KB
#include<bits/stdc++.h>
#include "secret.h"

using namespace std;

const int N = 1000;
const int logN = 10;

// int opCount = 0;
// int Secret(int x, int y) {
//     opCount++;
//     return (x + y) % (100000000);
// }

int lef[ N ][ logN ], rig[ N ][ logN ];
void build(int l, int r, int lev, int a[]) {
    if(l == r) {
        lef[ l ][ lev ] = a[ l ];
        rig[ r ][ lev ] = a[ r ];
        return;
    }
    int m = (l + r) / 2;
    for(int i = m + 1;i <= r;i++) {
        if(i == m + 1) rig[ i ][ lev ] = a[ i ];
        else rig[ i ][ lev ] = Secret(rig[i - 1][ lev ], a[ i ]);
    }
    for(int i = m;i >= l;i--) {
        if(i == m) lef[ i ][ lev ] = a[ i ];
        else lef[ i ][ lev ] = Secret(a[ i ], lef[i + 1][ lev ]);
    }

    build(l, m, lev + 1, a);
    build(m + 1, r, lev + 1, a);
}

int query(int ql, int qr, int l, int r, int lev) {
    if(l == r) 
        return lef[ l ][ lev ];
    int m = (l + r) / 2;
    if(ql <= m && m < qr) {
        return Secret(lef[ ql ][ lev ], rig[ qr ][ lev ]); 
    }
    if(qr <= m)
        return query(ql, qr, l, m, lev + 1);
    return query(ql, qr, m + 1, r, lev + 1);
}
int n;
void Init(int nn, int a[]) {
    n = nn;
    build(0, n - 1, 0, a);
}

int Query(int l, int r) {
    return query(l, r, 0, n - 1, 0);
}


// int main() {
//     int n;
//     cin >> n;
//     vector<int> a(n);
//     init(n, a);
//     cout << opCount;
// }
# 결과 실행 시간 메모리 Grader output
1 Correct 122 ms 2384 KB Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1
2 Correct 123 ms 2308 KB Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1
3 Incorrect 116 ms 2436 KB Wrong Answer: Query(1, 384) - expected : 153270594, actual : 469954882.
4 Incorrect 427 ms 4256 KB Wrong Answer: Query(193, 615) - expected : 280593123, actual : 511713615.
5 Incorrect 425 ms 4240 KB Wrong Answer: Query(397, 606) - expected : 375524436, actual : 66402808.
6 Incorrect 431 ms 4356 KB Wrong Answer: Query(498, 503) - expected : 522922284, actual : 922765812.
7 Incorrect 428 ms 4284 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 794702233.
8 Incorrect 424 ms 4300 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 895279321.
9 Incorrect 434 ms 4280 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 760376136.
10 Incorrect 427 ms 4336 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 773787723.