답안 #160564

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
160564 2019-10-28T13:39:53 Z nvmdava 비밀 (JOI14_secret) C++17
100 / 100
729 ms 8452 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(a[i], val[i + 1][m1]);
    }
    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, N - 1);
}

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:49:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# 결과 실행 시간 메모리 Grader output
1 Correct 185 ms 6380 KB Output is correct - number of calls to Secret by Init = 3084, maximum number of calls to Secret by Query = 1
2 Correct 177 ms 6364 KB Output is correct - number of calls to Secret by Init = 3092, maximum number of calls to Secret by Query = 1
3 Correct 177 ms 6396 KB Output is correct - number of calls to Secret by Init = 3100, maximum number of calls to Secret by Query = 1
4 Correct 610 ms 8312 KB Output is correct - number of calls to Secret by Init = 6988, maximum number of calls to Secret by Query = 1
5 Correct 618 ms 8220 KB Output is correct - number of calls to Secret by Init = 6996, maximum number of calls to Secret by Query = 1
6 Correct 599 ms 8452 KB Output is correct - number of calls to Secret by Init = 6996, maximum number of calls to Secret by Query = 1
7 Correct 613 ms 8352 KB Output is correct - number of calls to Secret by Init = 6996, maximum number of calls to Secret by Query = 1
8 Correct 729 ms 8296 KB Output is correct - number of calls to Secret by Init = 6996, maximum number of calls to Secret by Query = 1
9 Correct 617 ms 8252 KB Output is correct - number of calls to Secret by Init = 6996, maximum number of calls to Secret by Query = 1
10 Correct 615 ms 8316 KB Output is correct - number of calls to Secret by Init = 6996, maximum number of calls to Secret by Query = 1