Submission #13384

# Submission time Handle Problem Language Result Execution time Memory
13384 2015-02-15T05:24:09 Z gs14004 Secret (JOI14_secret) C++14
0 / 100
633 ms 5148 KB
#include "secret.h"
#include <algorithm>
using namespace std;

int t[10][1005];

void make(int depth, int A[], int N, int piv){
    if(depth == -1) return;
    make(depth-1,A,N,piv - (1<<(depth-1)));
    make(depth-1,A,N,piv + (1<<(depth-1)));
    int np = min(piv-1,N-1);
    t[depth][np] = A[np];
    for (int i=np-1; i>=piv - (1<<depth); i--) {
        t[depth][i] = Secret(A[i],t[depth][i+1]);
    }
    if(N <= piv) return;
    t[depth][piv] = A[piv];
    for (int i=piv+1; i<piv + (1<<depth) && i < N; i++) {
        t[depth][i] = Secret(t[depth][i-1],A[i]);
    }
}

void Init(int N, int A[]){
    make(9,A,N,512);
    for (int i=0; i<10; i++) {
        for (int j=0; j<N; j++) {
           // printf("%d ",t[i][j]);
        }
      //  puts("");
    }
}

int q(int p, int l, int r, int d){
    //printf("%d %d [%d,%d]\n",p,d,l,r);
    if(l <= p-1 && p <= r) return Secret(t[d][l],t[d][r]);
    if(r == p-1) return t[d][l];
    if(l == p) return t[d][r];
    if(r <= p-1) return q(p-(1<<(d-1)),l,r,d-1);
    return q(p+(1<<(d-1)),l,r,d-1);
}

int Query(int L, int R){
    return q(512,L,R,9);
}

Compilation message


# Verdict Execution time Memory Grader output
1 Incorrect 159 ms 5148 KB Wrong Answer: Query(366, 510) - expected : 538132672, actual : 282227072.
2 Correct 186 ms 5148 KB Output is correct - number of calls to Secret by Init = 4097, maximum number of calls to Secret by Query = 1
3 Correct 173 ms 5148 KB Output is correct - number of calls to Secret by Init = 4097, maximum number of calls to Secret by Query = 1
4 Correct 623 ms 5148 KB Output is correct - number of calls to Secret by Init = 7991, maximum number of calls to Secret by Query = 1
5 Correct 603 ms 5148 KB Output is correct - number of calls to Secret by Init = 8000, maximum number of calls to Secret by Query = 1
6 Correct 606 ms 5148 KB Output is correct - number of calls to Secret by Init = 8000, maximum number of calls to Secret by Query = 1
7 Correct 633 ms 5148 KB Output is correct - number of calls to Secret by Init = 8000, maximum number of calls to Secret by Query = 1
8 Correct 619 ms 5148 KB Output is correct - number of calls to Secret by Init = 8000, maximum number of calls to Secret by Query = 1
9 Correct 613 ms 5148 KB Output is correct - number of calls to Secret by Init = 8000, maximum number of calls to Secret by Query = 1
10 Correct 596 ms 5148 KB Output is correct - number of calls to Secret by Init = 8000, maximum number of calls to Secret by Query = 1