Submission #294361

# Submission time Handle Problem Language Result Execution time Memory
294361 2020-09-08T20:06:36 Z fucking_do_it Secret (JOI14_secret) C++14
0 / 100
20000 ms 8440 KB
#include "secret.h"
#include <bits/stdc++.h>
#define mid (l+r)/2
using namespace std;
const int inf = 1e3+9;
int n,a[inf],cnt;
int dp[inf][inf];

void build(int l,int r){

    if(l == r)
        return ;

    for(int i=mid-1;i>=l;i--)
        dp[i][mid] = Secret(a[i],dp[i+1][mid]);

    for(int i = mid+2;i<=r;i++)
        dp[mid+1][i] = Secret(dp[mid+1][i-1],a[i]);

    build(l,mid);
    build(mid+1,r);
}

void Init(int N, int A[]) {

    n = N;
    for(int i=1;i<=n;i++)
        a[i] = A[i-1],dp[i][i] = a[i];
    build(1,n);
    assert(cnt<=8000);

}

int Query(int x, int y) {
    x++,y++;
    int l = 1,r = n;
    while(l != r){
        if(x <= mid && y>= mid+1)
            return Secret(dp[x][mid],dp[mid+1][y]);
       if(x>mid)
            l = mid+1;
       else
            r = mid;
    }
 }

Compilation message

secret.cpp: In function 'int Query(int, int)':
secret.cpp:45:2: warning: control reaches end of non-void function [-Wreturn-type]
   45 |  }
      |  ^
# Verdict Execution time Memory Grader output
1 Execution timed out 20100 ms 4472 KB Time limit exceeded
2 Execution timed out 20058 ms 4472 KB Time limit exceeded
3 Execution timed out 20038 ms 4472 KB Time limit exceeded
4 Execution timed out 20066 ms 8300 KB Time limit exceeded
5 Execution timed out 20069 ms 8212 KB Time limit exceeded
6 Execution timed out 20045 ms 8312 KB Time limit exceeded
7 Correct 510 ms 8440 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
8 Correct 513 ms 8440 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
9 Correct 506 ms 8440 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
10 Correct 508 ms 8312 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1