Submission #13383

# Submission time Handle Problem Language Result Execution time Memory
13383 2015-02-15T05:17:08 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];
int *pt;
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)));
    if(N <= piv) return;
    t[depth][piv-1] = A[piv-1];
    t[depth][piv] = A[piv];
    for (int i=piv-2; i>=piv - (1<<depth); i--) {
        t[depth][i] = Secret(A[i],t[depth][i+1]);
    }
    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[]){
    pt = 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(d == 0) return pt[p];
    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 Correct 169 ms 5148 KB Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1
2 Incorrect 163 ms 5148 KB Wrong Answer: Query(332, 511) - expected : 666908073, actual : 0.
3 Correct 176 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 613 ms 5148 KB Output is correct - number of calls to Secret by Init = 7979, maximum number of calls to Secret by Query = 1
5 Correct 623 ms 5148 KB Output is correct - number of calls to Secret by Init = 7986, maximum number of calls to Secret by Query = 1
6 Incorrect 609 ms 5148 KB Wrong Answer: Query(993, 999) - expected : 329331970, actual : 0.
7 Correct 616 ms 5148 KB Output is correct - number of calls to Secret by Init = 7986, maximum number of calls to Secret by Query = 1
8 Correct 616 ms 5148 KB Output is correct - number of calls to Secret by Init = 7986, maximum number of calls to Secret by Query = 1
9 Correct 619 ms 5148 KB Output is correct - number of calls to Secret by Init = 7986, maximum number of calls to Secret by Query = 1
10 Correct 633 ms 5148 KB Output is correct - number of calls to Secret by Init = 7986, maximum number of calls to Secret by Query = 1