# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
439834 | julian33 | Secret (JOI14_secret) | C++14 | 564 ms | 4548 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "secret.h"
using namespace std;
#ifdef LOCAL
#define deb(...) logger(#__VA_ARGS__, __VA_ARGS__)
template<typename ...Args>
void logger(string vars, Args&&... values) {
cerr<<vars<<" = ";
string delim="";
(...,(cerr<<delim<<values,delim=", "));
cerr<<"\n";
}
#else
#define deb(...) logger(#__VA_ARGS__, __VA_ARGS__)
template<typename ...Args>
void logger(string vars, Args&&... values) {}
#endif
#define pb push_back
#define sz(x) (int)(x.size())
#define MAX_VALUE 1000000000
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> inline void maxa(T& a,T b){a=max(a,b);}
template<typename T> inline void mina(T& a,T b){a=min(a,b);}
const int mxN=1e3+5;
int a[mxN],pieceofshit[mxN][12],n;
void build(int v,int l,int r){
if(l>=r)
return;
int mid=(l+r)>>1;
build(v+1,l,mid);
build(v+1,mid+1,r);
pieceofshit[mid][v]=a[mid];
pieceofshit[mid+1][v]=a[mid+1];
for(int i=mid-1;i>=l;i--){
assert(pieceofshit[i+1][v]<=1e9);
pieceofshit[i][v]=Secret(a[i],pieceofshit[i+1][v]);
}
for(int i=mid+2;i<=r;i++){
assert(pieceofshit[i-1][v]<=1e9);
pieceofshit[i][v]=Secret(pieceofshit[i-1][v],a[i]);
}
deb(l,r,mid);
for(int i=l;i<=r;i++)
cerr<<pieceofshit[i][v]<<" \n"[i==r];
}
int query(int v,int l,int r,int lq,int rq){
int mid=(l+r)>>1;
if(lq>mid+1)
return query(v+1,mid+1,r,lq,rq);
if(rq<mid)
return query(v+1,l,mid,lq,rq);
if(lq<=mid && rq>mid){
assert(pieceofshit[lq][v]<=1e9);
assert(pieceofshit[rq][v]<=1e9);
return Secret(pieceofshit[lq][v],pieceofshit[rq][v]);
}
if(lq==mid+1)
return pieceofshit[rq][v];
if(rq==mid)
return pieceofshit[lq][v];
assert(false);
}
int Query(int L, int R){
if(L==R)
return a[L];
return query(0,0,n-1,L,R);
}
void Init(int N, int A[]){
for(int i=0;i<N;i++)
a[i]=A[i];
build(0,0,N-1);
n=N;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |