답안 #222915

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
222915 2020-04-14T10:45:44 Z lyc 비밀 (JOI14_secret) C++14
6 / 100
546 ms 4520 KB
#include "secret.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];

    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(v[h][i+j-1],a[i+j]);   // NOT commutative!
                }
            }
        }
    }

    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);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 149 ms 2552 KB Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1
2 Correct 153 ms 2680 KB Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1
3 Partially correct 156 ms 2552 KB Output isn't correct - number of calls to Secret by Init = 8194, maximum number of calls to Secret by Query = 1
4 Partially correct 522 ms 4380 KB Output isn't correct - number of calls to Secret by Init = 8194, maximum number of calls to Secret by Query = 1
5 Partially correct 515 ms 4456 KB Output isn't correct - number of calls to Secret by Init = 8194, maximum number of calls to Secret by Query = 1
6 Partially correct 534 ms 4468 KB Output isn't correct - number of calls to Secret by Init = 8194, maximum number of calls to Secret by Query = 1
7 Partially correct 544 ms 4424 KB Output isn't correct - number of calls to Secret by Init = 8194, maximum number of calls to Secret by Query = 1
8 Partially correct 546 ms 4408 KB Output isn't correct - number of calls to Secret by Init = 8194, maximum number of calls to Secret by Query = 1
9 Partially correct 534 ms 4520 KB Output isn't correct - number of calls to Secret by Init = 8194, maximum number of calls to Secret by Query = 1
10 Partially correct 539 ms 4344 KB Output isn't correct - number of calls to Secret by Init = 8194, maximum number of calls to Secret by Query = 1