Submission #1138068

#TimeUsernameProblemLanguageResultExecution timeMemory
1138068SmuggingSpunSecret (JOI14_secret)C++20
0 / 100
333 ms4448 KiB
#include "secret.h"
#include<bits/stdc++.h>
using namespace std;
const int lim = 1e3 + 5;
int a[lim], spt[lim][8];
void Init(int n, int A[]){
	for(int i = 0; i < n; i++){
		a[i] = A[i];
	}
	for(int i = n - 2; i > -1; i--){
		spt[i][0] = Secret(a[i], a[i + 1]); 
	}
	for(int j = 1; j < 8; j++){
		for(int i = 0; i + (1 << (j + 1)) - 1 < n; i++){
			spt[i][j] = Secret(spt[i][j - 1], spt[i + (1 << j)][j - 1]);
		}
	}
}
int Query(int l, int r){
	int ans = a[++l];
	while(l < r){
		for(int i = 7; i > -1; i--){
			if(l + (1 << (i + 1)) - 1 <= r){
				ans = Secret(ans, spt[l][i]);
				l += 1 << (i + 1);
				break;
			}
		}
	}
	return l == r ? Secret(ans, a[l]) : ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...