Submission #520006

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

const int M = 1000;
int a[M];

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;i<=m-lx;i++){
			pref[x][i] = ask(pref[x][i-1], a[m-i]);
		}
		
		suff[x][0] = a[m+1];
		for(int i=1;i<=rx-m-1;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[]) {
	for(int i=0;i<N;i++){
		a[i] = A[i];
	}
	
	tree.build();
}

int Query(int L, int R) {
	return tree.get(L, R);
}

Compilation message

secret.cpp: In function 'void Init(int, int*)':
secret.cpp:21:35: warning: array subscript 1000 is above array bounds of 'int [1000]' [-Warray-bounds]
   21 |   if(lx == rx) { pref[x][0] = a[lx]; return; }
      |                               ~~~~^
secret.cpp:9:5: note: while referencing 'a'
    9 | int a[M];
      |     ^
# Verdict Execution time Memory Grader output
1 Incorrect 128 ms 14212 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 50679111.
2 Incorrect 116 ms 14220 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 891888096.
3 Incorrect 118 ms 14208 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 10742098.
4 Incorrect 428 ms 16088 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 560152598.
5 Incorrect 440 ms 16124 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 497583184.
6 Incorrect 435 ms 16088 KB Wrong Answer: Query(738, 741) - expected : 983692994, actual : 302576192.
7 Incorrect 428 ms 16148 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 657493000.
8 Incorrect 428 ms 16236 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 764569728.
9 Incorrect 455 ms 16132 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 277877441.
10 Incorrect 429 ms 16068 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 69725386.