# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
885379 |
2023-12-09T14:53:55 Z |
Yey |
Secret (JOI14_secret) |
C++14 |
|
0 ms |
0 KB |
#include <bits/stdc++.h>
#include "quiz.h"
using namespace std;
int node[10][1030];
int n;
int b[1030];
int x;
int mx = 0;
void build(int depth,int l,int r){
int m = (l+r)/2;
if( !(0 <= m && m < x) ) return;
node[depth][m] = b[m];
for(int i = m-1 ; i >= l ; i--){
node[depth][i] = getClue(b[i],node[depth][i+1]);
}
if( m+1 < r && m+1 < x ){
node[depth][m+1] = b[m+1];
for(int i = m+2; i < r ; i++){
if( 0 <= i && i < x ) node[depth][i] = getClue(b[i],node[depth][i-1]);
}
}
//~ cout<<depth<<":\n";
//~ for(int i = l ; i < r ; i++) if( i < x ) cout<<i<<" "<<node[depth][i]<<"\n";
if( r-l > 1 ){
build(depth+1,l,m);
build(depth+1,m,r);
}
}
int q(int l,int r){
if( l == r ) return b[l];
int p = __builtin_clz(l^r) ^ 31;
int pp = mx - 1 - p;
//~ cout<<p<<"\n";
int res = node[pp][l];
if(r & ((1<<p) - 1)){
res = getClue(res,node[p][r]);
}
return res;
}
void init(int N, std::vector<int> a) {
x = n = N;
int k = 1;
while( k < n ) {
k *= 2;
mx++;
}
n = k;
for(int i = 0 ; i < (int) a.size() ; i++) b[i] = a[i];
build(0,0,n);
}
int query(int l, int r) {
return q(l,r);
return 0;
}
Compilation message
secret.cpp:2:10: fatal error: quiz.h: No such file or directory
2 | #include "quiz.h"
| ^~~~~~~~
compilation terminated.