//#pragma optimization_level 3
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#include"secret.h"
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordset;
*/
#define fr first
#define sc second
#define vec vector
#define pb push_back
#define pii pair<int, int>
#define forn(x,y) for(ll x = 1 ; x <= y ; ++x)
#define all(x) (x).begin(),(x).end()
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef pair<ll,ll> pll;
const int nmax = 100005;
const ll linf = 1e17;
const ll mod = 1e9+7;
const int inf = 1e9+7;
const ll lim = 1e4;
int n, a[nmax];
map < pii , int > cl;
map < pii , int > rg;
int Ask(int a, int b){
if( cl[make_pair(a,b)] != 0){
return cl[make_pair(a,b)];
}
else
return cl[make_pair(a,b)] = Secret(a,b);
}
int Ask_range(int l , int r){
assert(rg[make_pair(l,r)] != 0);
return rg[make_pair(l,r)];
}
void make_range(int l , int r){
if(l == r){
return;
}
int mid = (l+r)>>1;
int as = a[mid];
int bs = a[mid+1];
for(int i = mid - 1 ; i >= l ; i--){
as = Ask(a[i],as);
rg[make_pair(i,mid)] = as;
}
for(int i = mid + 2 ; i <= r ; i++){
bs = Ask(bs,a[i]);
rg[make_pair(mid+1,i)] = bs;
}
make_range(l,mid);
make_range(mid+1,r);
}
void Init(int N , int A[]){
n = N;
forn(i,n){
a[i] = A[i-1];
}
make_range(1,n);
}
int qr(int l, int r , int lt , int rt){
int mid = (lt+rt)>>1;
if(r <= mid){
return qr(l,r,lt,mid);
}
if(l >= mid + 1){
return qr(l,r,mid+1,rt);
}
return Ask(Ask_range(l,mid),Ask_range(mid+1,r));
}
int Query(int L , int R){
L++, R++;
if( L == R ){
return a[L];
}
if( L == R - 1){
return Ask(a[L],a[R]);
}
return qr(L,R,1,n);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
147 ms |
5500 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Runtime error |
146 ms |
5496 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Runtime error |
146 ms |
5496 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Runtime error |
515 ms |
10744 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
5 |
Runtime error |
525 ms |
10492 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
6 |
Runtime error |
521 ms |
10500 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
7 |
Correct |
533 ms |
5924 KB |
Output is correct - number of calls to Secret by Init = 7491, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
535 ms |
5880 KB |
Output is correct - number of calls to Secret by Init = 7491, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
539 ms |
5952 KB |
Output is correct - number of calls to Secret by Init = 7491, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
538 ms |
6044 KB |
Output is correct - number of calls to Secret by Init = 7491, maximum number of calls to Secret by Query = 1 |