Submission #639153

# Submission time Handle Problem Language Result Execution time Memory
639153 2022-09-08T18:09:02 Z phoenix Secret (JOI14_secret) C++17
0 / 100
436 ms 4452 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(r - l <= 1) {
        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(lef[i + 1][ lev ], a[ i ]);
    }

    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;
// }
# Verdict Execution time Memory Grader output
1 Incorrect 114 ms 2396 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 268854015.
2 Incorrect 112 ms 2348 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 311474560.
3 Incorrect 116 ms 2368 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 353554500.
4 Incorrect 420 ms 4452 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 343081568.
5 Incorrect 433 ms 4244 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 957013316.
6 Incorrect 436 ms 4408 KB Wrong Answer: Query(915, 915) - expected : 282904741, actual : 0.
7 Incorrect 427 ms 4284 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 675449873.
8 Incorrect 425 ms 4348 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 273091792.
9 Incorrect 432 ms 4420 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 827853577.
10 Incorrect 428 ms 4292 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 337854787.