Submission #546741

# Submission time Handle Problem Language Result Execution time Memory
546741 2022-04-08T11:02:05 Z krit3379 Secret (JOI14_secret) C++17
0 / 100
486 ms 8424 KB
#include "secret.h"
#include<bits/stdc++.h>
using namespace std;
#define N 1005

int n,dp[N][N];

int sol(int l,int r,int *a){
    if(dp[l][r]!=-1)return dp[l][r];
    if(l==r)return dp[l][r]=a[l];
    int mid=(l+r)/2;
    sol(l,mid,a);
    sol(mid+1,r,a);
    for(int i=l;i<=mid;i++)dp[i][r]=Secret(dp[i][mid],dp[mid+1][r]);
}

void Init(int nn, int *a){
    n=nn;
    for(int i=0;i<n;i++)for(int j=0;j<n;j++)dp[i][j]=-1;
    sol(0,(n-1)/2,a);
    if(n>1)sol((n-1)/2+1,n-1,a);
}

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

Compilation message

secret.cpp: In function 'int sol(int, int, int*)':
secret.cpp:15:1: warning: control reaches end of non-void function [-Wreturn-type]
   15 | }
      | ^
secret.cpp: In function 'int Query(int, int)':
secret.cpp:33:1: warning: control reaches end of non-void function [-Wreturn-type]
   33 | }
      | ^
# Verdict Execution time Memory Grader output
1 Incorrect 127 ms 4428 KB Wrong Answer [1]
2 Incorrect 116 ms 4380 KB Wrong Answer [1]
3 Incorrect 127 ms 4428 KB Wrong Answer [1]
4 Incorrect 455 ms 8268 KB Wrong Answer [1]
5 Incorrect 473 ms 8188 KB Wrong Answer [1]
6 Incorrect 468 ms 8216 KB Wrong Answer [1]
7 Incorrect 469 ms 8276 KB Wrong Answer [1]
8 Incorrect 486 ms 8424 KB Wrong Answer [1]
9 Incorrect 465 ms 8196 KB Wrong Answer [1]
10 Incorrect 486 ms 8244 KB Wrong Answer [1]