답안 #881971

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
881971 2023-12-02T11:01:59 Z Alan 비밀 (JOI14_secret) C++17
0 / 100
376 ms 8288 KB
#include <bits/stdc++.h>
using namespace std;

int Secret(int X, int Y);

int ans[1005][1005], N;

void calc (int l, int r) {
	if (l == r) return;
	int mid = (l+r)/2;
	for (int i = mid-1; i >= l; i--) if (ans[i][mid] == -1) ans[i][mid] = Secret(i, mid);
	for (int i = mid+2; i <= r; i++) if (ans[mid+1][i] == -1) ans[mid+1][i] = Secret(mid+1, i);
	calc(l, mid);
	calc(mid+1, r);
}

void Init (int n, int A[]) {
	N = n;
	for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) ans[i][j] = -1;
	for (int i = 0; i < n; i++) ans[i][i] = A[i];
	calc(0, n-1);
}

int solve (int l, int r, int ql, int qr) {
	int mid = (l+r)/2;
	if (qr <= mid) return solve(l, mid, ql, qr);
	if (mid+1 <= l) return solve(mid+1, r, ql, qr);
	return Secret(ans[ql][mid], ans[mid+1][qr]);
}

int Query (int L, int R) {
	if (ans[L][R] != -1) return ans[L][R];
	return solve(0, N-1, L, R);
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 99 ms 6744 KB Wrong Answer [1]
2 Incorrect 102 ms 6748 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 271581344.
3 Incorrect 99 ms 6748 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 564398162.
4 Incorrect 373 ms 8288 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 393773658.
5 Incorrect 376 ms 8284 KB Wrong Answer [1]
6 Incorrect 376 ms 8272 KB Wrong Answer [1]
7 Incorrect 374 ms 8272 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 676897831.
8 Incorrect 369 ms 8276 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 547447763.
9 Incorrect 376 ms 8280 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 1975398.
10 Incorrect 372 ms 8276 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 808152387.