Submission #885389

# Submission time Handle Problem Language Result Execution time Memory
885389 2023-12-09T15:00:58 Z Yey Secret (JOI14_secret) C++14
0 / 100
377 ms 4572 KB
#include <bits/stdc++.h>
#include "secret.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] = Secret(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] = Secret(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 = Secret(res,node[p][r]);
	}
	return res;
}

void Init(int N, int a[]) {
	x = n = N;
	int k = 1;
	while( k < n ) {
		k *= 2;
		mx++;
	}
	n = k;
	for(int i = 0 ; i < (int) N ; i++) b[i] = a[i];
	build(0,0,n);
}

int Query(int l, int r) {
	return q(l,r);
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 101 ms 2652 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 274020174.
2 Incorrect 102 ms 2640 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 617844841.
3 Incorrect 101 ms 2848 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 414599674.
4 Incorrect 374 ms 4572 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 546029766.
5 Incorrect 370 ms 4432 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 543199320.
6 Incorrect 374 ms 4432 KB Wrong Answer: Query(738, 741) - expected : 983692994, actual : 285337044.
7 Incorrect 376 ms 4344 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 719882280.
8 Incorrect 375 ms 4496 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 29746368.
9 Incorrect 377 ms 4436 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 408297858.
10 Incorrect 377 ms 4504 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 809805827.