답안 #293362

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
293362 2020-09-08T00:37:40 Z XmtosX 비밀 (JOI14_secret) C++17
100 / 100
513 ms 8572 KB
#include <bits/stdc++.h>;
#include "secret.h"
using namespace std;
#define LL pos*2+1
#define RR pos*2+2
const int NN=1e3+3;
int a[NN],n,ans[NN][NN],l,r;
void solve(int st,int en)
{
    if (st>en)
        return;
    int mid=(st+en)/2;
    ans[mid][mid]=a[mid];
    ans[mid+1][mid+1]=a[mid+1];
    if (st==en)
        return;
    for (int i=mid+2;i<=en;i++)
        ans[mid+1][i]=Secret(ans[mid+1][i-1],a[i]);
    for (int i=mid-1;i>=st;i--)
        ans[i][mid]=Secret(a[i],ans[i+1][mid]);
    solve(st,mid);
    solve(mid+1,en);
}
int query(int st,int en)
{
    int mid=(st+en)/2;
    if (mid>r)
        return query(st,mid);
    if (mid<l)
        return query(mid+1,en);
    if (r==mid)
        return ans[l][r];
    return Secret(ans[l][mid],ans[mid+1][r]);
}
void Init(int N, int A[])
{
    n=N;
    for (int i=0;i<n;i++)
        a[i]=A[i];
    solve(0,n-1);
}
int Query(int L, int R)
{
    l=L;
    r=R;
    return query(0,n-1);
}
/*
8
1 4 7 2 5 8 3 6
4
0 3
1 7
5 5
2 4
*/

Compilation message

secret.cpp:1:25: warning: extra tokens at end of #include directive
    1 | #include <bits/stdc++.h>;
      |                         ^
# 결과 실행 시간 메모리 Grader output
1 Correct 146 ms 4476 KB Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1
2 Correct 148 ms 4472 KB Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1
3 Correct 147 ms 4472 KB Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1
4 Correct 511 ms 8312 KB Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1
5 Correct 507 ms 8184 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
6 Correct 513 ms 8572 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
7 Correct 512 ms 8192 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
8 Correct 512 ms 8184 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
9 Correct 510 ms 8452 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
10 Correct 505 ms 8184 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1