답안 #652554

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
652554 2022-10-23T06:25:37 Z rsjw 비밀 (JOI14_secret) C++17
0 / 100
455 ms 4500 KB
#include "secret.h"
int n;
int a[1005];

int f[8][1005];
void divi(int l = 1, int r = n, int rt = 0) {
	if (l == r || l + 1 == r)
		return;
	int m = (l + r) / 2, i;
	f[rt][m] = a[m];
	f[rt][m + 1] = a[m + 1];
	for (i = m - 1; i >= l; i--)
		f[rt][i] = Secret(a[i], f[rt][i + 1]);
	for (i = m + 2; i <= r; i++)
		f[rt][i] = Secret(f[rt][i - 1], a[i]);
	divi(l, m, rt + 1);
	divi(m + 1, r, rt + 1);
}
int dS(int L, int R, int l = 1, int r = n, int rt = 0) {
	int m = (l + r) / 2, i;
	if (R <= m)
		return dS(L, R, l, m, rt + 1);
	if (L > m)
		return dS(L, R, m + 1, r, rt + 1);
	return rt;
}
void Init(int N, int A[]) {
	int i;
	n = N;
	for (int i = 1; i <= n; i++)
		a[i] = A[i - 1];
	divi();
}
int Query(int L, int R) {
	L++, R++;
	if (L == R)
		return a[L];
	if (L + 1 == R)
		return Secret(a[L], a[R]);
	int rt = dS(L, R);
	return Secret(f[rt][L], f[rt][R]);
}

Compilation message

secret.cpp: In function 'int dS(int, int, int, int, int)':
secret.cpp:20:23: warning: unused variable 'i' [-Wunused-variable]
   20 |  int m = (l + r) / 2, i;
      |                       ^
secret.cpp: In function 'void Init(int, int*)':
secret.cpp:28:6: warning: unused variable 'i' [-Wunused-variable]
   28 |  int i;
      |      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 127 ms 2536 KB Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1
2 Correct 126 ms 2472 KB Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1
3 Correct 123 ms 2380 KB Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1
4 Incorrect 432 ms 4284 KB Wrong Answer: Query(955, 956) - expected : 283256648, actual : 287040792.
5 Incorrect 432 ms 4416 KB Wrong Answer: Query(957, 957) - expected : 115761809, actual : 479625358.
6 Incorrect 444 ms 4388 KB Wrong Answer: Query(915, 915) - expected : 282904741, actual : 424136318.
7 Correct 434 ms 4340 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
8 Correct 455 ms 4500 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
9 Correct 451 ms 4344 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1
10 Correct 453 ms 4320 KB Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1