답안 #488399

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
488399 2021-11-18T19:41:21 Z AmirElarbi 비밀 (JOI14_secret) C++14
100 / 100
442 ms 8328 KB
#include <bits/stdc++.h>
#include "secret.h"
#define vi vector<int>
#define ve vector
#define ll long long
#define vf vector<float>
#define vll vector<pair<ll,ll>>
#define ii pair<int,int>
#define vvi vector<vi>
#define vii vector<ii>
#define gii greater<ii>
#define pb push_back
#define fi first
#define se second
#define INF 1e9
#define eps 1e-7
#define eps1 1e-25
#define optimise ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MAX_A 1e5+5
#define V 450
using namespace std;
const int MOD = 1e9+7;
const int nax = 2005;
int n;
vi s;
int t[nax][nax];
void solve(int L, int R) {
    int md = (L + R)/2;
    t[md][md] = s[md];
    t[md + 1][md + 1] = s[md + 1];
    for(int l = md + 2; l <= R; l++)
        t[md + 1][l] = Secret(t[md + 1][l - 1], s[l]);
    for(int l = md - 1; l >= L; l--)
        t[md][l] = Secret(s[l], t[md][l+1]);
    if(L < md) solve(L, md);
    if(md + 1 < R) solve(md + 1, R);
}   
void Init(int N, int A[]){
    n = N;
    for (int i = 0; i < N; ++i)
    {
        s.pb(A[i]);
    }
    solve(0,n-1);
}
int Query(int L, int R){
    int l = 0, r = n-1;
    while(l != r){
        int md = (l+r)/2;
        if(md >= L && md < R)
                    return Secret(t[md][L], t[md+1][R]);
        else if(md == R) return t[md][L];
        else if(md < L)
            l = md+1;
        else
            r = md;
    }
    return t[l][l];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 117 ms 4436 KB Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1
2 Correct 117 ms 4368 KB Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1
3 Correct 136 ms 4380 KB Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1
4 Correct 423 ms 8276 KB Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1
5 Correct 434 ms 8328 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
6 Correct 414 ms 8308 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
7 Correct 433 ms 8260 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
8 Correct 415 ms 8300 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 8288 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
10 Correct 419 ms 8280 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1