Submission #520007

# Submission time Handle Problem Language Result Execution time Memory
520007 2022-01-28T05:50:23 Z amunduzbaev Secret (JOI14_secret) C++14
0 / 100
437 ms 16324 KB
#include "bits/stdc++.h"
#include "secret.h"
using namespace std;
#ifndef EVAL
#include "grader.cpp"
#endif

const int M = 1005;
int a[M], NN;

int ask(int a, int b){
	if(a == -1) return b;
	if(b == -1) return a;
	return Secret(a, b);
}

struct ST{
	int pref[M<<2][M], suff[M<<2][M];
	
	void build(int lx = 0, int rx = M, int x = 1){
		if(lx == rx) { pref[x][0] = a[lx]; return; }
		int m = (lx + rx) >> 1;
		pref[x][0] = a[m];
		for(int i=1;m-i>=lx;i++){
			pref[x][i] = ask(pref[x][i-1], a[m-i]);
		}
		
		suff[x][0] = a[m+1];
		for(int i=1;m+1+i<=rx;i++){
			suff[x][i] = ask(suff[x][i-1], a[m+1+i]);
		}
		
		build(lx, m, x<<1);
		build(m+1, rx, x<<1|1);
	}
	
	int get(int l, int r, int lx = 0, int rx = M, int x = 1){
		if(lx == rx) return a[lx];
		int m = (lx + rx) >> 1;
		if(r <= m) return get(l, r, lx, m, x<<1);
		if(m < l) return get(l, r, m+1, rx, x<<1|1);
		return ask(pref[x][m-l], suff[x][r-m-1]);
	}
}tree;

void Init(int N, int A[]) {
	NN = N;
	for(int i=0;i<N;i++){
		a[i] = A[i];
	}
	
	tree.build(0, NN - 1, 1);
}

int Query(int L, int R) {
	return tree.get(L, R, 0, NN - 1, 1);
}
# Verdict Execution time Memory Grader output
1 Incorrect 114 ms 8456 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 268854015.
2 Incorrect 118 ms 8356 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 311474560.
3 Incorrect 118 ms 8408 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 353554500.
4 Incorrect 418 ms 16008 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 343081568.
5 Incorrect 430 ms 16048 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 957013316.
6 Incorrect 433 ms 16324 KB Wrong Answer: Query(200, 208) - expected : 277813445, actual : 154975445.
7 Incorrect 423 ms 16036 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 675449873.
8 Incorrect 437 ms 16072 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 273091792.
9 Incorrect 428 ms 15956 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 827853577.
10 Incorrect 427 ms 16052 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 337854787.