답안 #321637

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
321637 2020-11-13T00:41:44 Z peuch 비밀 (JOI14_secret) C++17
0 / 100
514 ms 9868 KB
#include "secret.h"
#include<bits/stdc++.h>

const int MAXN = 1010;

int n;
long long value[MAXN][MAXN];
long long v[MAXN];

void dc(int ini, int fim){
	if(ini == fim) {
		value[ini][ini] = v[ini];
		return;
	}
	int mid = (ini + fim) / 2;

	dc(ini, mid);
	dc(mid + 1, fim);

	value[mid][mid] = v[mid];
	for(int i = mid - 1; i >= ini; i--)
		value[i][mid] = Secret(value[i + 1][mid], v[i]);

	value[mid + 1][mid + 1] = v[mid + 1];
	for(int i = mid + 2; i <= fim; i++)
		value[mid + 1][i] = Secret(value[mid + 1][i - 1], v[i]);
}

long long getVal(int ini, int fim, int l, int r){
	// printf("\t%d %d\n", ini, fim);
	if(ini == fim) return value[ini][ini];
	int mid = (ini + fim) / 2;
	if(l <= mid && r > mid)
		return Secret(value[l][mid], value[mid + 1][r]);
	if(r <= mid)
		return getVal(ini, mid, l, r);
	return getVal(mid + 1, fim, l, r);
}

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

int Query(int L, int R) {
	// printf("Query: %d %d\n", L, R);
	if(L == R) return v[L];
	return getVal(0, n - 1, L, R);
}

//g++ -o secret -O2 grader.cpp secret.cpp
# 결과 실행 시간 메모리 Grader output
1 Incorrect 132 ms 4844 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 268854015.
2 Incorrect 135 ms 4844 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 311474560.
3 Incorrect 134 ms 4844 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 353554500.
4 Incorrect 495 ms 9600 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 343081568.
5 Incorrect 499 ms 9772 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 957013316.
6 Incorrect 503 ms 9580 KB Wrong Answer: Query(200, 208) - expected : 277813445, actual : 154975445.
7 Incorrect 504 ms 9688 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 675449873.
8 Incorrect 514 ms 9868 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 273091792.
9 Incorrect 504 ms 9580 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 827853577.
10 Incorrect 502 ms 9708 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 337854787.