Submission #77267

# Submission time Handle Problem Language Result Execution time Memory
77267 2018-09-24T14:23:16 Z MohamedAhmed0 Secret (JOI14_secret) C++14
0 / 100
619 ms 8476 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] ;
    if(arr1[left][right] != 0)
        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 arr1[left][right] = Secret(x , y);
    else if(x == -1)
        return arr1[left][right] = y ;
    else if(y == -1)
        return arr1[left][right] = 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)
{
    return solve(0 , n-1 , l , r);
}

Compilation message

secret.cpp: In function 'int solve(int, int, int, int)':
secret.cpp:37:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Incorrect 166 ms 4472 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 303446001.
2 Incorrect 166 ms 4476 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 401641632.
3 Incorrect 167 ms 4536 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 76556308.
4 Incorrect 603 ms 8376 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 652837005.
5 Incorrect 616 ms 8376 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 947541334.
6 Incorrect 619 ms 8456 KB Wrong Answer: Query(915, 915) - expected : 282904741, actual : 941867304.
7 Incorrect 607 ms 8456 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 690201657.
8 Incorrect 619 ms 8456 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 812884248.
9 Incorrect 603 ms 8476 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 299244610.
10 Incorrect 604 ms 8476 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 875372551.