Submission #94803

# Submission time Handle Problem Language Result Execution time Memory
94803 2019-01-24T06:05:52 Z Retro3014 Secret (JOI14_secret) C++17
0 / 100
477 ms 8572 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)	{
		dp[x][y] = v[x];
		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;
		}
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 130 ms 4472 KB Wrong Answer: Query(113, 206) - expected : 536899947, actual : 538256673.
2 Incorrect 130 ms 4384 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 311474560.
3 Incorrect 131 ms 4472 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 353554500.
4 Incorrect 477 ms 8372 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 343081568.
5 Incorrect 477 ms 8572 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 957013316.
6 Incorrect 473 ms 8308 KB Wrong Answer: Query(250, 258) - expected : 907404, actual : 997709.
7 Incorrect 472 ms 8220 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 675449873.
8 Incorrect 467 ms 8312 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 273091792.
9 Incorrect 468 ms 8504 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 827853577.
10 Incorrect 471 ms 8328 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 337854787.