Submission #53907

# Submission time Handle Problem Language Result Execution time Memory
53907 2018-07-01T17:32:29 Z jovan_b Secret (JOI14_secret) C++17
0 / 100
698 ms 8856 KB
#include <bits/stdc++.h>
#include "secret.h"

using namespace std;
typedef long long ll;

int niz[1005];
int res[1005][2][1005];
int n;

int fajnd(int l, int r, int trl, int trr){
    if(r-l <= 1) return -1;
    int mid = (l+r)/2;
    if(l <= trl && trr <= r && trl <= mid && r >= mid) return mid;
    int x = fajnd(l, mid, trl, trr);
    if(x != -1) return x;
    return fajnd(mid+1, r, trl, trr);
}

void process(int l, int r){
    if(r-l <= 1) return;
    int i = (l+r)/2;
    res[i][0][i] = niz[i];
    res[i][1][i+1] = niz[i+1];
    for(int j=i-1; j>=l; j--){
        res[i][0][j] = Secret(niz[j], res[i][0][j+1]);
    }
    for(int j=i+2; j<=r; j++){
        res[i][1][j] = Secret(res[i][1][j-1], niz[j]);
    }
    process(l, i);
    process(i+1, r);
}

void Init(int N, int A[]){
    n = N;
    for(int i=0; i<N; i++) niz[i+1] = A[i];
    process(1, n);
}

int Query(int L, int R){
    L++;
    R++;
    if(L == R) return niz[L];
    if(R == L+1) return Secret(niz[L], niz[R]);
    int i = fajnd(1, n, L, R);
    return Secret(res[i][0][L], res[i][1][R]);
}

# Verdict Execution time Memory Grader output
1 Incorrect 165 ms 4600 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 587620235.
2 Incorrect 162 ms 4600 KB Wrong Answer: Query(102, 157) - expected : 32612619, actual : 962726377.
3 Incorrect 164 ms 4600 KB Wrong Answer: Query(334, 369) - expected : 363022362, actual : 16889894.
4 Incorrect 597 ms 8476 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 846921768.
5 Incorrect 587 ms 8492 KB Wrong Answer: Query(263, 292) - expected : 653448456, actual : 710055954.
6 Incorrect 645 ms 8564 KB Wrong Answer: Query(738, 741) - expected : 983692994, actual : 949167361.
7 Correct 645 ms 8636 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
8 Correct 644 ms 8692 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
9 Correct 602 ms 8728 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
10 Correct 698 ms 8856 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1