답안 #957089

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
957089 2024-04-02T23:52:33 Z MuntherCarrot 비밀 (JOI14_secret) C++14
0 / 100
397 ms 8284 KB
#include <bits/stdc++.h>
#include "secret.h"

using namespace std;

// int Secret(int X, int Y);

const int MAXN = 1010;
int block[MAXN][MAXN];
int n;

void div(int l, int r, int A[]){
    if(l >= r){
        block[l][l] = A[l];
        return;
    }
    int mid = (l + r) / 2;
    block[mid][mid] = A[mid];
    block[mid + 1][mid + 1] = A[mid + 1];
    for(int i = mid - 1; i >= l; i--){
        block[mid][i] = Secret(A[i], block[mid][i + 1]);
    }
    for(int i = mid + 2; i <= r; i++){
        block[mid + 1][i] = Secret(block[mid + 1][i - 1], A[i]);
    }
    div(l, mid, A);
    div(mid + 1, r, A);
}

void Init(int N, int A[]){
    n = N;
    div(0, N - 1, A);
}

int Query(int L, int R){
    int l = 0, r = n - 1;
    while(l <= r){
        int mid = (l + r) / 2;
        if(L <= mid && mid < R){
            return Secret(block[mid][L], block[mid + 1][R]);
        }
        else if(mid == R){
            return block[mid][L];
        }
        else if(mid < L){
            l = mid + 1;
        }
        else{
            r = mid - 1;
        }
    }
    return block[l][l];
}

// by me
# 결과 실행 시간 메모리 Grader output
1 Correct 109 ms 6748 KB Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1
2 Correct 112 ms 6788 KB Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1
3 Incorrect 101 ms 6744 KB Wrong Answer: Query(67, 224) - expected : 202440844, actual : 536870912.
4 Incorrect 372 ms 8284 KB Wrong Answer: Query(384, 458) - expected : 896057572, actual : 536870912.
5 Incorrect 397 ms 8284 KB Wrong Answer: Query(263, 292) - expected : 653448456, actual : 536870912.
6 Incorrect 375 ms 8276 KB Wrong Answer: Query(738, 741) - expected : 983692994, actual : 0.
7 Correct 391 ms 8284 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
8 Correct 395 ms 8276 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
9 Correct 397 ms 8284 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
10 Correct 389 ms 8276 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1