답안 #1100469

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1100469 2024-10-14T03:30:17 Z anhphant 비밀 (JOI14_secret) C++14
0 / 100
305 ms 4720 KB
#include <bits/stdc++.h>
#include "secret.h"
using namespace std;
typedef long long  ll;

int N, A[1000007], Q;
ll dat[17][1007], mask[1007];
vector<ll> v;

// int Secret(int a, int b) {
// 	return a + b;
// }

void divi(ll l, ll r, ll lev, int A[]) {
	if (l == r) return;
	ll mid = (l + r) / 2;
	dat[lev][mid] = A[mid];
	for(int i = mid - 1; i >= l; --i) {
		dat[lev][i] = Secret(A[i], dat[lev][i + 1]);
	}
	dat[lev][mid + 1] = A[mid + 1];
	for(int i = mid + 2; i <= r; ++i) {
		dat[lev][i] = Secret(dat[lev][i - 1], A[i]);
	}
	for(int i = mid + 1; i <= r; ++i) mask[i] ^= (1 << lev);
	divi(l, mid, lev + 1, A);
	divi(mid + 1, r, lev + 1, A);
}

void Init(int N, int A[]) {
	cin >> N;
	for(int i = 1; i <= N; ++i) cin >> A[i];

	divi(1, N, 0, A);
	for(int i = 1; i <= N; ++i) v.push_back(A[i]);
}

int Query(int l, int r) {
	l++;
	r++;
	if (l == r) return v[l - 1];
	int bits = __builtin_ctz(mask[l] ^ mask[r]);
	return Secret(dat[bits][l], dat[bits][r]);
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 79 ms 4688 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 307655478.
2 Incorrect 78 ms 4688 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 539081064.
3 Incorrect 77 ms 4688 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 355475528.
4 Incorrect 302 ms 4700 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 569475659.
5 Incorrect 297 ms 4712 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 987791438.
6 Incorrect 300 ms 4720 KB Wrong Answer: Query(915, 915) - expected : 282904741, actual : 206870645.
7 Incorrect 296 ms 4656 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 785056803.
8 Incorrect 299 ms 4680 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 560296976.
9 Incorrect 305 ms 4708 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 299376775.
10 Incorrect 294 ms 4712 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 4663113.