답안 #386540

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
386540 2021-04-06T18:54:05 Z aryan12 비밀 (JOI14_secret) C++17
0 / 100
509 ms 8528 KB
#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
 
const int MAX_N = 1000;
 
int ans[MAX_N][MAX_N];
int N;
 
void PreCompute(int left, int right) {
    int mid = (left + right) >> 1;
    if(right - left <= 2)
        return;
    for(int i = mid - 2; i >= left; i--) {
        ans[i][mid - 1] = Secret(ans[i + 1][mid - 1], ans[i][i]);
    }
    for(int i = mid + 1; i < right; i++) {
        ans[mid][i] = Secret(ans[mid][i - 1], ans[i][i]);
    }
    PreCompute(left, mid);
    PreCompute(mid, right);
}
 
void Init(int n, int A[]) {
    N = n;
    for(int i = 0; i < N; i++) {
        for(int j = i; j < N; j++) {
            ans[i][j] = (i == j) ? A[i] : -1; 
        }
    }
    PreCompute(0, N);
}
 
int Compute(int left, int right, int ql, int qr) {
    int mid = (left + right) >> 1;
    if(ql >= mid) {
        return Compute(mid, right, ql, qr);
    }
    else if(qr < mid) {
        return Compute(left, mid, ql, qr);
    }
    return Secret(ans[ql][mid - 1], ans[mid][qr]);
}
 
int Query(int L, int R) {
    if(L == R)
        return ans[L][L];
    if(L == R - 1)
        return Secret(ans[L][L], ans[R][R]);
    return Compute(0, N, L, R);
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 137 ms 4460 KB Wrong Answer: Query(113, 206) - expected : 536899947, actual : 50471211.
2 Incorrect 133 ms 4424 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 311474560.
3 Incorrect 137 ms 4460 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 162768982.
4 Incorrect 509 ms 8300 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 858309235.
5 Incorrect 496 ms 8528 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 957013316.
6 Incorrect 495 ms 8328 KB Wrong Answer: Query(738, 741) - expected : 983692994, actual : 302576192.
7 Incorrect 501 ms 8192 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 675449873.
8 Incorrect 498 ms 8188 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 273091792.
9 Incorrect 498 ms 8172 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 827853577.
10 Incorrect 500 ms 8248 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 337854787.