Submission #468353

# Submission time Handle Problem Language Result Execution time Memory
468353 2021-08-27T19:53:35 Z stefantaga Secret (JOI14_secret) C++14
100 / 100
571 ms 8408 KB
#include "secret.h"
 
int val[1000][1000];
 
void init(int l, int r)
{
    if(r - l < 2) return;
    int mid = (l + r)/2;
    for(int i=mid-1;i>=l;i--)
    {
        if(val[i][mid] != -1) continue;
        val[i][mid] = Secret(val[i][i], val[i+1][mid]);
    }
    for(int j=mid+2;j<=r;j++)
    {
        if(val[mid+1][j] != -1) continue;
        val[mid+1][j] = Secret(val[mid+1][j-1], val[j][j]);
    }
    init(l, mid-1);
    init(mid+1, r);
}
 
void Init(int N, int A[]) {
    for(int i=0;i<N;i++) for(int j=0;j<N;j++) val[i][j] = -1;
    for(int i=0;i<N;i++)
    {
        val[i][i] = A[i];
    }
    init(0, N-1);
}
 
int Query(int L, int R) {
    if(val[L][R] != -1) return val[L][R];
    for(int i=L;i<R;i++)
    {
        if(val[L][i] != -1 && val[i+1][R] != -1)
        {
            return val[L][R] = Secret(val[L][i], val[i+1][R]);
        }
    }
}

Compilation message

secret.cpp: In function 'int Query(int, int)':
secret.cpp:41:1: warning: control reaches end of non-void function [-Wreturn-type]
   41 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 144 ms 4308 KB Output is correct - number of calls to Secret by Init = 3084, maximum number of calls to Secret by Query = 1
2 Correct 145 ms 4392 KB Output is correct - number of calls to Secret by Init = 3092, maximum number of calls to Secret by Query = 1
3 Correct 144 ms 4368 KB Output is correct - number of calls to Secret by Init = 3100, maximum number of calls to Secret by Query = 1
4 Correct 518 ms 8152 KB Output is correct - number of calls to Secret by Init = 6988, maximum number of calls to Secret by Query = 1
5 Correct 514 ms 8332 KB Output is correct - number of calls to Secret by Init = 6996, maximum number of calls to Secret by Query = 1
6 Correct 534 ms 8204 KB Output is correct - number of calls to Secret by Init = 6996, maximum number of calls to Secret by Query = 1
7 Correct 519 ms 8408 KB Output is correct - number of calls to Secret by Init = 6996, maximum number of calls to Secret by Query = 1
8 Correct 509 ms 8132 KB Output is correct - number of calls to Secret by Init = 6996, maximum number of calls to Secret by Query = 1
9 Correct 514 ms 8280 KB Output is correct - number of calls to Secret by Init = 6996, maximum number of calls to Secret by Query = 1
10 Correct 571 ms 8200 KB Output is correct - number of calls to Secret by Init = 6996, maximum number of calls to Secret by Query = 1