답안 #484042

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
484042 2021-11-01T23:49:18 Z danielliu04 비밀 (JOI14_secret) C++17
0 / 100
428 ms 4392 KB
// Link: https://cses.fi/problemset/task/1647

#include <bits/stdc++.h>
#include "secret.h"
using namespace std;

#define ll long long
#define lc (node<<1)+1
#define rc (node<<1)+2
#define endl '\n'
#define INF 1e9

const int max_n = 1000;
const int max_log = (int)log2(max_n) + 2;
int dat[max_log][max_n];
int arr[max_n], mask[max_n];

void divi(int left, int right, int level){
	if(left == right) return;
	int mid = (left + right) / 2;
	dat[level][mid] = arr[mid];
	for(int i = mid-1; i >= left; i --){
		dat[level][i] = Secret(dat[level][i+1], arr[i]);
	}
	dat[level][mid+1] = arr[mid+1];
	for(int i = mid+2; i <= right; i ++){
		dat[level][i] = Secret(dat[level][i-1], arr[i]);
	}
	for(int i = mid+1; i <= right; i ++){
		mask[i] |= (1 << level);
	}
	divi(left, mid, level+1); divi(mid+1, right, level + 1);
}

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

int Query(int L, int R){
	if(L == R) return arr[L];
	int bits = __builtin_ctz(mask[L] ^ mask[R]);
	return Secret(dat[bits][L], dat[bits][R]);
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 118 ms 2536 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 268854015.
2 Incorrect 118 ms 2496 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 311474560.
3 Incorrect 114 ms 2452 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 353554500.
4 Incorrect 427 ms 4292 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 343081568.
5 Incorrect 421 ms 4392 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 957013316.
6 Incorrect 418 ms 4292 KB Wrong Answer: Query(200, 208) - expected : 277813445, actual : 154975445.
7 Incorrect 428 ms 4328 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 675449873.
8 Incorrect 420 ms 4368 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 273091792.
9 Incorrect 418 ms 4328 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 827853577.
10 Incorrect 428 ms 4308 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 337854787.