Submission #439833

#TimeUsernameProblemLanguageResultExecution timeMemory
439833julian33Secret (JOI14_secret)C++14
0 / 100
559 ms4312 KiB
#include <bits/stdc++.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()) 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][10],n; int Secret(int X,int Y); // int Secret(int x,int y){ // return x^y; // } 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(pieceofshit[i+1][v],a[i]); } for(int i=mid+2;i<=r;i++){ assert(pieceofshit[i-1][v]<=1e9); pieceofshit[i][v]=Secret(pieceofshit[i-1][v],a[i]); } } 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 timeMemoryGrader output
Fetching results...