# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
286175 |
2020-08-30T08:00:16 Z |
YJU |
Secret (JOI14_secret) |
C++14 |
|
513 ms |
8696 KB |
#include<bits/stdc++.h>
#include "secret.h"
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll MOD=1e9+7;
const ll MOD2=998244353;
const ll N=1e3+5;
const ld pi=3.14159265359;
const ll INF=(1LL<<60);
#define SQ(i) ((i)*(i))
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define setp setprecision
#define lwb lower_bound
#define SZ(_a) (ll)_a.size()
int pre[N][N],suf[N][N],n,u[N];
void Init(int N,int *a){
n=N;
REP(i,n)u[i]=a[i];
function<void(int,int)> build = [&](int l,int r){
if(l>=r)return ;
ll mid=(l+r+1)/2;
build(l,mid-1);build(mid+1,r);
pre[mid][mid]=a[mid];
suf[mid][mid-1]=a[mid-1];
for(int i=mid+1;i<=r;i++)pre[mid][i]=Secret(pre[mid][i-1],a[i]);
for(int i=mid-2;i>=l;i--)suf[mid][i]=Secret(a[i],suf[mid][i+1]);
};
build(0,N-1);
}
int q(int l,int r,int ql,int qr){
ll mid=(l+r+1)/2;
if(qr<mid-1)return q(l,mid-1,ql,qr);
if(ql>mid)return q(mid+1,r,ql,qr);
if(ql==mid)return pre[mid][qr];
if(qr==mid-1)return suf[mid][ql];
return Secret(suf[mid][ql],pre[mid][qr]);
}
int Query(int L,int R){
if(L==R)return u[L];
return q(0,n-1,L,R);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
146 ms |
4600 KB |
Output is correct - number of calls to Secret by Init = 3331, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
150 ms |
4600 KB |
Output is correct - number of calls to Secret by Init = 3339, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
150 ms |
4600 KB |
Output is correct - number of calls to Secret by Init = 3347, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
511 ms |
8600 KB |
Output is correct - number of calls to Secret by Init = 7467, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
511 ms |
8568 KB |
Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
507 ms |
8568 KB |
Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
505 ms |
8568 KB |
Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
513 ms |
8440 KB |
Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
510 ms |
8696 KB |
Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
506 ms |
8568 KB |
Output is correct - number of calls to Secret by Init = 7476, maximum number of calls to Secret by Query = 1 |