답안 #77273

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
77273 2018-09-24T14:52:40 Z MohamedAhmed0 비밀 (JOI14_secret) C++14
30 / 100
725 ms 8792 KB
#include <bits/stdc++.h>
using namespace std ;
#include "secret.h"
int arr[100001] , arr1[1001][1001];
#define MAX_VALUE        1000000000

void build(int left , int right)
{
    if(left == right)
    {
        arr1[left][left] = arr[left];
        return ;
    }
    int mid = (left + right) >> 1 ;
    build(left , mid) ;
    build(mid + 1, right);
    arr1[left][right] = Secret(arr1[left][mid] , arr1[mid+1][right]);
}

int solve(int left , int right , int l , int r)
{
    if(left > r || right < l)
        return -1 ;
    if(left >= l && right <= r)
       return arr1[left][right] ;
    int mid = (left + right) >> 1 ;
    int x = solve(left , mid , l , r);
    int y = solve(mid + 1 , right , l , r);
    if(x != -1 && y != -1)
      return Secret(x , y);
    else if(x == -1)
        return y ;
    else if(y == -1)
        return x ;
}

int n ;

void Init(int N, int A[])
{
    //srand(time(NULL));
    n = N ;
    for(int i = 0 ; i < N ; ++i)
        arr[i] = A[i] ;
    build(0 , N-1);
    for(int i = 0 ; i < 1500 ; ++i)
    {
        int x = rand() % N , y = rand() % N ;
        arr1[x][y] = solve(0 , n-1 , x , y);
    }
}
int Query(int l, int r)
{
    if(arr1[l][r] != 0)
        return arr1[l][r];
    return arr1[l][r] = solve(0 , n-1 , l , r);
}

Compilation message

secret.cpp: In function 'int solve(int, int, int, int)':
secret.cpp:35:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# 결과 실행 시간 메모리 Grader output
1 Partially correct 241 ms 4472 KB Output is partially correct - number of calls to Secret by Init = 5006, maximum number of calls to Secret by Query = 13
2 Partially correct 227 ms 4480 KB Output is partially correct - number of calls to Secret by Init = 4962, maximum number of calls to Secret by Query = 14
3 Partially correct 237 ms 4680 KB Output is partially correct - number of calls to Secret by Init = 5080, maximum number of calls to Secret by Query = 15
4 Partially correct 685 ms 8620 KB Output is partially correct - number of calls to Secret by Init = 6111, maximum number of calls to Secret by Query = 15
5 Partially correct 687 ms 8620 KB Output is partially correct - number of calls to Secret by Init = 6323, maximum number of calls to Secret by Query = 15
6 Partially correct 633 ms 8620 KB Output is partially correct - number of calls to Secret by Init = 6323, maximum number of calls to Secret by Query = 4
7 Partially correct 714 ms 8620 KB Output is partially correct - number of calls to Secret by Init = 6323, maximum number of calls to Secret by Query = 16
8 Partially correct 704 ms 8636 KB Output is partially correct - number of calls to Secret by Init = 6323, maximum number of calls to Secret by Query = 16
9 Partially correct 715 ms 8792 KB Output is partially correct - number of calls to Secret by Init = 6323, maximum number of calls to Secret by Query = 16
10 Partially correct 725 ms 8792 KB Output is partially correct - number of calls to Secret by Init = 6323, maximum number of calls to Secret by Query = 16