Submission #735835

# Submission time Handle Problem Language Result Execution time Memory
735835 2023-05-04T18:43:50 Z sandry24 Secret (JOI14_secret) C++17
100 / 100
484 ms 12228 KB
#include <bits/stdc++.h>
#include "secret.h"
using namespace std;
 
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define pb push_back
#define mp make_pair
#define f first
#define s second

const int MAX_N = 1005;
int meetpoint[MAX_N][MAX_N];
int res[MAX_N][MAX_N];

void build(int l, int r){
    if(l >= r)
        return;
    int mid = (l+r)/2;
    for(int i = l; i <= mid; i++){
        for(int j = mid+1; j <= r; j++)
            meetpoint[i][j] = mid;
    }
    for(int i = mid+2; i <= r; i++)
        res[mid+1][i] = Secret(res[mid+1][i-1], res[i][i]);
    for(int i = mid-1; i >= l; i--)
        res[i][mid] = Secret(res[i][i], res[i+1][mid]);
    build(l, mid);
    build(mid+1, r);
}

void Init(int N, int A[]){
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            res[i][j] = (i == j ? A[i] : -1);
        }
    }
    build(0, N-1);
}

int Query(int L, int R){
    if(res[L][R] != -1)
        return res[L][R];
    int mid = meetpoint[L][R];
    return Secret(res[L][mid], res[mid+1][R]);
}
# Verdict Execution time Memory Grader output
1 Correct 139 ms 6348 KB Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1
2 Correct 128 ms 6300 KB Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1
3 Correct 123 ms 6464 KB Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1
4 Correct 442 ms 12116 KB Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1
5 Correct 484 ms 12096 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
6 Correct 438 ms 12060 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
7 Correct 434 ms 12028 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
8 Correct 473 ms 12228 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
9 Correct 442 ms 12108 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
10 Correct 435 ms 12136 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1