Submission #752588

# Submission time Handle Problem Language Result Execution time Memory
752588 2023-06-03T09:17:46 Z jamezzz Secret (JOI14_secret) C++17
0 / 100
446 ms 8696 KB
#include "secret.h"
#include <bits/stdc++.h>
using namespace std;

#define pf printf

int n,a[1024],st[12][1024];

inline int ask(int x,int y){
	if(x==-1)return y;
	if(y==-1)return x;
	return Secret(x,y);
}

void build(int lvl,int l,int r){
	int m=(l+r)>>1;
	int pv=-1;
	for(int i=m;i>=l;--i){
		pv=st[lvl][i]=ask(a[i],pv);
	}
	pv=-1;
	for(int i=m+1;i<=r;++i){
		pv=st[lvl][i]=ask(pv,a[i]);
	}
	if(l==r)return;
	build(lvl-1,l,m);
	build(lvl-1,m+1,r);
}

void Init(int N,int A[]){
	n=N;
	for(int i=0;i<n;++i)a[i]=A[i];
	int lvl=31-__builtin_clz(n);
	int sz=n;
	if((1<<lvl)!=n)++lvl,sz=1<<lvl;
	for(int i=n;i<sz;++i)a[i]=-1;
	build(lvl-1,0,sz-1);
}

int Query(int L,int R){
	int lvl=31-__builtin_clz(L^R);
	return L==R?st[lvl][L]:ask(st[lvl][L],st[lvl][R]);
}
# Verdict Execution time Memory Grader output
1 Runtime error 114 ms 4676 KB Execution killed with signal 11
2 Runtime error 132 ms 4744 KB Execution killed with signal 11
3 Runtime error 113 ms 4724 KB Execution killed with signal 11
4 Runtime error 423 ms 8616 KB Execution killed with signal 11
5 Runtime error 423 ms 8616 KB Execution killed with signal 11
6 Runtime error 435 ms 8696 KB Execution killed with signal 11
7 Runtime error 445 ms 8592 KB Execution killed with signal 11
8 Runtime error 443 ms 8644 KB Execution killed with signal 11
9 Runtime error 446 ms 8552 KB Execution killed with signal 11
10 Runtime error 424 ms 8576 KB Execution killed with signal 11