답안 #94802

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
94802 2019-01-24T05:58:09 Z Retro3014 비밀 (JOI14_secret) C++17
0 / 100
485 ms 8440 KB
#include "secret.h"
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <iostream>

using namespace std;

#define MAX_N 1000

vector<int> v;
int n;
int dp[MAX_N+1][MAX_N+1];

void init(int x, int y){
	if(x==y)	return;
	if(x==y-1){
		dp[x][y] = Secret(v[x], v[y]);
		return;
	}
	int m = (x+y)/2;
	dp[m][m] = v[m];
	dp[m+1][m+1] = v[m+1];
	for(int i=m-1; i>=x; i--)	dp[i][m] = Secret(dp[i+1][m], v[i]);
	for(int j=m+2; j<=y; j++)	dp[m+1][j] = Secret(dp[m+1][j-1], v[j]);
	init(x, m);
	init(m+1, y);
}


void Init(int N, int A[]) {n = N;
	for(int i=0; i<N; i++){
		v.push_back(A[i]);
	}
	init(0, N-1);
}

int Query(int L, int R) {
	if(L==R){
		return v[L];
	}
	if(L==R-1){
		return Secret(v[L], v[R]);
	}
	int s = 0, e = n-1, m;
	while(1){
		m = (s+e)/2;
		if(L<=m && R>m){
			return Secret(dp[L][m], dp[m+1][R]);
		}
		if(R<=m){
			e = m;
		}else{
			s = m+1;
		}
	}
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 131 ms 4472 KB Wrong Answer: Query(113, 206) - expected : 536899947, actual : 538256673.
2 Incorrect 132 ms 4456 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 311474560.
3 Incorrect 129 ms 4536 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 353554500.
4 Incorrect 477 ms 8440 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 343081568.
5 Incorrect 476 ms 8412 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 957013316.
6 Incorrect 480 ms 8348 KB Wrong Answer: Query(250, 258) - expected : 907404, actual : 997709.
7 Incorrect 480 ms 8396 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 675449873.
8 Incorrect 485 ms 8440 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 273091792.
9 Incorrect 482 ms 8440 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 827853577.
10 Incorrect 481 ms 8440 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 337854787.