# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1094765 |
2024-09-30T13:28:50 Z |
asli_bg |
Secret (JOI14_secret) |
C++11 |
|
317 ms |
4536 KB |
#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define FOR(i,a) for(int i=0;i<(a);i++)
#define FORE(i,a,b) for(int i=(a);i<(b);i++)
#define cont(x) {for(auto el:x) cout<<el<<' ';cout<<endl;}
#define contp(x) {for(auto el:x) cout<<el.fi<<'-'<<el.se<<' ';cout<<endl;}
#define sp <<" "<<
#define mid (l+r)/2
#define endl '\n'
#define DEBUG(X) {cout<<#X<<' '<<(X)<<endl;}
#define carp(x,y) ((x%MOD)*(y%MOD))%MOD
#define topla(x,y) ((x%MOD)+(y%MOD))%MOD
typedef vector<int> vi;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<bool> vb;
const int MAXN=1e3+5;
const int MAXK=15;
#include "secret.h"
vi a;
int n;
int tut[MAXK][MAXN];
int mask[MAXN];
void dq(int l,int r,int lev){
if(l>=r) return;
tut[lev][mid]=a[mid];
tut[lev][mid+1]=a[mid+1];
for(int i=mid-1;i>=l;i--){
tut[lev][i]=Secret(a[i],tut[lev][i+1]);
}
for(int i=mid+2;i<=r;i++){
tut[lev][i]=Secret(tut[lev][i-1],a[i]);
}
FORE(i,mid+1,r+1) mask[i]=mask[i]^(1<<lev);
dq(l,mid,lev+1);
dq(mid+1,r,lev+1);
}
void Init(int N, int A[]) {
n=N;
a.pb(0);
FOR(i,N){
a.pb(A[i]);
}
dq(1,n,0);
}
int Query(int l, int r) {
l++;r++;
if(l==r) return a[l];
int bits=__builtin_ctz(mask[l]^mask[r]);
return Secret(tut[bits][l],tut[bits][r]);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
86 ms |
2388 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
87 ms |
2388 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
84 ms |
2644 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
307 ms |
4436 KB |
Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
311 ms |
4488 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
310 ms |
4536 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
311 ms |
4416 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
317 ms |
4436 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
309 ms |
4352 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
314 ms |
4436 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |