Submission #160559

# Submission time Handle Problem Language Result Execution time Memory
160559 2019-10-28T13:28:15 Z nvmdava Secret (JOI14_secret) C++17
0 / 100
713 ms 8440 KB
#include "secret.h"
#include <bits/stdc++.h>

int val[1005][1005];
int a[1005];

void get(int l, int r){
    if(l > r)
        return;
    if(l == r){
        val[l][l] = a[l];
        return;
    }

    int m1 = (l + r) >> 1;
    int m2 = m1 + 1;

    val[m1][m1] = a[m1];
    val[m2][m2] = a[m2];

    for(int i = m1 - 1; i >= l; i--){
        val[i][m1] = val[m1][i] = Secret(val[i + 1][m1], a[i]);
    }
    for(int i = m2 + 1; i <= r; i++){
        val[i][m2] = val[m2][i] = Secret(val[i - 1][m2], a[i]);
    }

    get(l, m1 - 1);
    get(m2 + 1, r);
}

void Init(int N, int A[]){

    memset(val, -1, sizeof val);

    for(int i = 0; i < N; i++)
        a[i] = A[i];

    get(0, 1000);

}

int Query(int L, int R) {
    if(val[L][R] != -1)
        return val[L][R];
    for(int i = L; i < R; i++){
        if(val[L][i] != -1 && val[i + 1][R] != -1)
            return Secret(val[L][i], val[i + 1][R]);
    }
}

Compilation message

secret.cpp: In function 'int Query(int, int)':
secret.cpp:50:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Incorrect 166 ms 6392 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 575693743.
2 Incorrect 168 ms 6316 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 528123936.
3 Incorrect 173 ms 6516 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 428171264.
4 Incorrect 713 ms 8312 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 343081568.
5 Incorrect 610 ms 8440 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 4326416.
6 Incorrect 603 ms 8364 KB Wrong Answer: Query(738, 741) - expected : 983692994, actual : 313045306.
7 Incorrect 621 ms 8336 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 657493000.
8 Incorrect 599 ms 8328 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 764569728.
9 Incorrect 597 ms 8440 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 277877441.
10 Incorrect 606 ms 8236 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 69725386.