답안 #525915

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
525915 2022-02-13T07:52:59 Z Nihal_9936 비밀 (JOI14_secret) C++14
0 / 100
434 ms 8312 KB
#include <bits/stdc++.h>
using namespace std;
#include "secret.h"

int dp[1001][1001];
int n;

void solve(int f, int l, int A[]){
	int mid = (f + l) / 2;
	dp[mid][mid] = A[mid];
	dp[mid + 1][mid + 1] = A[mid + 1];

	for(int i = mid - 1; i >= f; i--){
		dp[mid][i] = Secret(A[i], dp[mid][i + 1]);
	}

	for(int i = mid + 2; i <= l; i++){
		dp[mid + 1][i] = Secret(A[i], dp[mid + 1][i - 1]);
	}

	if(f < mid) solve(f, mid, A);
	if(mid + 1 < l) solve(mid + 1, l, A); 
}


void Init(int N, int A[]) {
	// for(int i = 0; i < 1001; i++){
	// 	for(int j = 0; j < 1001; j++){
	// 		dp[i][j] = -1;
	// 	}
	// }
	n = N;
	solve(0, n - 1, A);
}

int Query(int l, int r){
	int f = 0, ls = n - 1;
	while(true){
		int mid = (f + ls) / 2;
		if(l <= mid and mid < r){
			return Secret(dp[mid][l], dp[mid + 1][r]);
		}
		if(mid == r) return dp[mid][l];

		if(r <= mid){
			ls = mid;
		}else{
			f = mid + 1;
		}
	}
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 113 ms 4356 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 809782271.
2 Incorrect 117 ms 4288 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 68749376.
3 Incorrect 125 ms 4352 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 136349820.
4 Incorrect 434 ms 8132 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 650789536.
5 Incorrect 430 ms 8312 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 377506838.
6 Incorrect 428 ms 8116 KB Wrong Answer: Query(738, 741) - expected : 983692994, actual : 61461050.
7 Incorrect 432 ms 8244 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 687550570.
8 Incorrect 429 ms 8148 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 145923264.
9 Incorrect 433 ms 8156 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 18757135.
10 Incorrect 432 ms 8152 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 70590726.