Submission #740352

# Submission time Handle Problem Language Result Execution time Memory
740352 2023-05-12T11:27:16 Z BidoTeima Secret (JOI14_secret) C++17
100 / 100
463 ms 8364 KB
#include "secret.h"
#include <bits/stdc++.h>
const int N = 1e3;
int val[N][N];
int a[N];
void rec(int l, int r){
    if(l > r)
        return;
    if(l == r){
        val[l][l] = a[l];
        return;
    }
    int mid = (l + r) >> 1;
    // (l, mid), (l + 1, mid), ..., (mid, mid)
    val[mid][mid] = a[mid];
    for(int i = mid-1; i >= l; i--){
      val[i][mid] = Secret(a[i], val[i+1][mid]);
    }
  val[mid+1][mid+1] = a[mid+1];
    for(int i = mid + 2; i <= r; i++){
        val[mid+1][i] = Secret(val[mid+1][i-1], a[i]);
    }
    rec(l, mid);
    rec(mid + 1, r);
}
void Init(int n, int A[]) {
    for(int i = 0; i < n; i++){
        a[i] = A[i];
    }
    memset(val, -1, sizeof(val));
    rec(0, n - 1);
}
 
int Query(int L, int R) {
    if(L == R)
        return val[L][L];
    for(int i = L; i + 1 <= R; i++){
        if(val[L][i] != -1 && val[i + 1][R] != -1)
            return Secret(val[L][i], val[i + 1][R]);
    }
    if(val[L][R] != -1)
        return val[L][R];
    return -1;
}
# Verdict Execution time Memory Grader output
1 Correct 127 ms 6276 KB Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1
2 Correct 126 ms 6284 KB Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1
3 Correct 126 ms 6296 KB Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1
4 Correct 461 ms 8140 KB Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1
5 Correct 435 ms 8140 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
6 Correct 442 ms 8364 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
7 Correct 445 ms 8304 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
8 Correct 463 ms 8152 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
9 Correct 460 ms 8132 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
10 Correct 445 ms 8092 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1