Submission #77268

# Submission time Handle Problem Language Result Execution time Memory
77268 2018-09-24T14:31:32 Z MohamedAhmed0 Secret (JOI14_secret) C++14
Compilation error
0 ms 0 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[])
{
    n = N ;
    for(int i = 0 ; i < N ; ++i)
        arr[i] = A[i] ;
    build(0 , N-1);
}
int Query(int l, int r)
{
    if(arr1[left][right] != 0)
        return arr1[left][right];
    return solve(0 , n-1 , l , r);
}

Compilation message

secret.cpp: In function 'int Query(int, int)':
secret.cpp:48:17: error: invalid types 'int [1001][1001][std::ios_base&(std::ios_base&)]' for array subscript
     if(arr1[left][right] != 0)
                 ^
secret.cpp:49:25: error: invalid types 'int [1001][1001][std::ios_base&(std::ios_base&)]' for array subscript
         return arr1[left][right];
                         ^
secret.cpp: In function 'int solve(int, int, int, int)':
secret.cpp:35:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^