//#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 |
146 ms |
5600 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 |
147 ms |
5592 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Runtime error |
530 ms |
10556 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
5 |
Runtime error |
523 ms |
10588 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
6 |
Runtime error |
524 ms |
10532 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
7 |
Correct |
543 ms |
6008 KB |
Output is correct - number of calls to Secret by Init = 7491, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
541 ms |
6024 KB |
Output is correct - number of calls to Secret by Init = 7491, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
538 ms |
6008 KB |
Output is correct - number of calls to Secret by Init = 7491, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
548 ms |
5984 KB |
Output is correct - number of calls to Secret by Init = 7491, maximum number of calls to Secret by Query = 1 |