# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
439835 | julian33 | Secret (JOI14_secret) | C++14 | 755 ms | 4492 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())
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;
typedef pair<vector<int>,vector<int>> pvv;
int a[mxN];
vector<pair<pii,pvv>> interval;
vector<int> graph[mxN];
// int Secret(int x,int y){
// return x^y;
// }
int cnt=0;
void build(int l,int r){
if(l>=r)
return;
int mid=(l+r)>>1;
vector<int> lft,rt;
lft.pb(a[mid]); rt.pb(a[mid+1]);
for(int i=mid+2;i<=r;i++){
cnt++;
assert(cnt<=8e3);
rt.pb(Secret(rt.back(),a[i]));
}
for(int i=mid-1;i>=l;i--){
cnt++;
assert(cnt<=8e3);
lft.pb(Secret(a[i],lft.back()));
}
interval.pb({{l,r},{lft,rt}});
build(l,mid); build(mid+1,r);
}
int Query(int L, int R){
L++; R++;
if(L==R)
return a[L];
for(auto u:interval){
int l=u.first.first;
int r=u.first.second;
int mid=(l+r)>>1;
if(R<mid || R>r)
continue;
if(L>mid+1 || L<l)
continue;
if(R==mid){
int want=mid-L;
return u.second.first[want];
}
if(L==mid+1){
int want=R-mid-1;
return u.second.second[want];
}
int lwant=mid-L;
int rwant=R-mid-1;
return Secret(u.second.first[lwant],u.second.second[rwant]);
}
assert(false);
}
void Init(int N, int A[]){
for(int i=0;i<N;i++)
a[i+1]=A[i];
build(1,N);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |