Submission #222904

# Submission time Handle Problem Language Result Execution time Memory
222904 2020-04-14T10:33:43 Z lyc Secret (JOI14_secret) C++14
0 / 100
544 ms 4600 KB
#include "secret.h"
#include <bits/stdc++.h>
using namespace std;

#define SZ(x) ((int)(x).size())
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)

struct DST {
    static const int MX_N = 1024;
    static const int LG_N = 10;
    static const int E = 0;
    static inline int func(int x, int y) { return Secret(x,y); }

    int N, v[LG_N+1][MX_N+1];

    inline void build(int n, int *a) {
        for (N = 1; N < n; N <<= 1);
        FOR(i,0,n-1) v[0][i] = a[i];
        FOR(i,n,N-1) v[0][i] = E;

        for (int h = 1, seg = 2; seg <= N; ++h, seg <<= 1) {
            for (int i = seg>>1, ss = (seg>>1)-1; i < N; i += seg) {
                v[h][i] = a[i];
                v[h][i-1] = a[i-1];
                FOR(j,1,ss){
                    v[h][i-1-j] = func(a[i-1-j],v[h][i-j]);
                    v[h][i+j] = func(a[i+j],v[h][i+j-1]);
                }
            }
        }
    }

    int query(int i, int j) {
        if (i == j) return v[0][i];
        int h = (31-__builtin_clz(i^j)) + 1; // MSB + 1
        return func(v[h][i],v[h][j]);
    }
} dst;

void Init(int N, int A[]) {
    dst.build(N,A);
}

int Query(int L, int R) {
    return dst.query(L,R);
}
# Verdict Execution time Memory Grader output
1 Incorrect 142 ms 2552 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 809782271.
2 Incorrect 142 ms 2680 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 68749376.
3 Incorrect 141 ms 2552 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 145096996.
4 Incorrect 508 ms 4476 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 70926549.
5 Incorrect 514 ms 4416 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 849351688.
6 Incorrect 524 ms 4600 KB Wrong Answer: Query(738, 741) - expected : 983692994, actual : 722663411.
7 Incorrect 528 ms 4472 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 661138442.
8 Incorrect 544 ms 4600 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 878738504.
9 Incorrect 530 ms 4472 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 26754469.
10 Incorrect 514 ms 4472 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 7889739.