Submission #412482

# Submission time Handle Problem Language Result Execution time Memory
412482 2021-05-27T01:23:35 Z songc Secret (JOI14_secret) C++14
0 / 100
529 ms 4372 KB
#include "secret.h"

int N;
int A[1010], T[20][1010];

void dnc(int d, int s, int e){
	if (s == e) return;
	int m=s+e>>1;
	T[d][m+1] = A[m+1];
	for (int i=m+2; i<=e; i++) T[d][i] = Secret(T[d][i-1], A[i]);
	T[d][m] = A[m];
	for (int i=m-1; i>=s; i--) T[d][i] = Secret(A[i], T[d][i+1]);
	dnc(d+1, s, m), dnc(d+1, m+1, e);
}

void Init(int _N, int P[]){
	N = _N;
	for (int i=0; i<N; i++) A[i] = P[i];
	dnc(0, 0, N-1);
}

int qry(int d, int s, int e, int ts, int te){
	int m=s+e>>1;
	if (ts <= m && m <= te) return Secret(T[d][ts], T[d][te]);
	if (te <= m) return qry(d+1, s, m, ts, te);
	return qry(d+1, m+1, e, ts, te);
}

int Query(int L, int R){
	if (L == R) return A[L];
	return qry(0, 0, N-1, L, R);
}

Compilation message

secret.cpp: In function 'void dnc(int, int, int)':
secret.cpp:8:9: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    8 |  int m=s+e>>1;
      |        ~^~
secret.cpp: In function 'int qry(int, int, int, int, int)':
secret.cpp:23:9: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   23 |  int m=s+e>>1;
      |        ~^~
# Verdict Execution time Memory Grader output
1 Incorrect 145 ms 2432 KB Wrong Answer: Query(264, 271) - expected : 675707686, actual : 675306646.
2 Incorrect 147 ms 2412 KB Wrong Answer: Query(210, 211) - expected : 558550312, actual : 706802953.
3 Incorrect 137 ms 2288 KB Wrong Answer: Query(352, 384) - expected : 142799164, actual : 488954194.
4 Incorrect 522 ms 4252 KB Wrong Answer: Query(571, 624) - expected : 309502044, actual : 665002674.
5 Incorrect 516 ms 4372 KB Wrong Answer: Query(323, 499) - expected : 244860236, actual : 408602960.
6 Incorrect 529 ms 4188 KB Wrong Answer: Query(747, 749) - expected : 244228265, actual : 788987922.
7 Correct 507 ms 4292 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
8 Correct 519 ms 4296 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
9 Correct 517 ms 4272 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
10 Correct 507 ms 4288 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1