Submission #866000

# Submission time Handle Problem Language Result Execution time Memory
866000 2023-10-25T09:27:36 Z lolismek Secret (JOI14_secret) C++14
0 / 100
404 ms 8636 KB
#include "secret.h"

#include <vector>
#include <iostream>

using namespace std;


const int NMAX = 1000;

int n;
int a[NMAX + 1];
int dp[10][NMAX + 1];

void divide(int level, int l, int r){
    if(l == r){
        dp[level][l] = a[l];
        return;
    }

    int mid = (l + r) / 2;

    dp[level][mid] = a[mid];
    for(int i = mid - 1; i >= l; i--){
        dp[level][i] = Secret(a[i], dp[level][i + 1]);
    }
    dp[level][mid + 1] = a[mid + 1];
    for(int i = mid + 2; i <= r; i++){
        dp[level][i] = Secret(dp[level][i - 1], a[i]);
    }

    divide(level + 1, l, mid);
    divide(level + 1, mid + 1, r);
}

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

int getAns(int level, int l, int r, int L, int R){
    int mid = (l + r) / 2;
    if(L <= mid && mid <= R){
        return Secret(dp[level][L], dp[level][R]);
    }

    if(mid < L){
        return getAns(level + 1, mid + 1, r, L, R);
    }
    return getAns(level + 1, l, mid, L, R);
}
int Query(int L, int R){
    if(L == R){
        return a[L];
    }
    return getAns(1, 0, n - 1, L, R);
    return 0;
}

# Verdict Execution time Memory Grader output
1 Incorrect 102 ms 2652 KB Wrong Answer: Query(264, 271) - expected : 675707686, actual : 675306646.
2 Incorrect 104 ms 2904 KB Wrong Answer: Query(210, 211) - expected : 558550312, actual : 706802953.
3 Incorrect 101 ms 2652 KB Wrong Answer: Query(352, 384) - expected : 142799164, actual : 488954194.
4 Runtime error 377 ms 8504 KB Execution killed with signal 11
5 Runtime error 383 ms 8556 KB Execution killed with signal 11
6 Incorrect 374 ms 4292 KB Wrong Answer: Query(915, 915) - expected : 282904741, actual : 547105756.
7 Runtime error 378 ms 8552 KB Execution killed with signal 11
8 Runtime error 404 ms 8548 KB Execution killed with signal 11
9 Runtime error 381 ms 8636 KB Execution killed with signal 11
10 Runtime error 391 ms 8548 KB Execution killed with signal 11