답안 #170983

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
170983 2019-12-26T21:53:20 Z ZwariowanyMarcin 비밀 (JOI14_secret) C++14
0 / 100
600 ms 4616 KB
#include "secret.h"
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define ss(x) (int) x.size()
#define pb push_back
#define ll long long
#define cat(x) cerr << #x << " = " << x << endl
#define FOR(i, n) for(int i = 0; i < n; ++i)

using namespace std;

int n;
int a[1024];
int val[1024][11];

void dc(int l, int r, int lvl) {
	if(l >= r) return;
	int m = (l + r) / 2;
	val[m][lvl] = a[m];
	for(int j = m - 1; l <= j; --j)
		val[j][lvl] = Secret(a[j], val[j + 1][lvl]);
	val[m + 1][lvl] = a[m + 1];
	for(int j = m + 2; j <= r; ++j)
		val[j][lvl] = Secret(a[j], val[j - 1][lvl]);
	dc(l, m, lvl + 1);
	dc(m + 1, r, lvl + 1);
}

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

int solve(int x, int y, int l, int r, int lvl = 0) {
	int m = (l + r) / 2;
	if(x <= m && m + 1 <= y) 
		return Secret(val[x][lvl], val[y][lvl]);
	if(y <= m)
		return solve(x, y, l, m, lvl + 1);
	return solve(x, y, m + 1, r, lvl + 1);
}

int Query(int l, int r) {
	if(l == r) return a[l];
	return solve(l, r, 0, n - 1);
}

/*int main() {
	int A[] = {1, 4, 7, 2, 5, 8, 3, 6};
	Init(8, A);
	cout << Query(0, 3) << endl;
	cout << Query(1, 7) << endl;
	cout << Query(5, 5) << endl;
	cout << Query(2, 4) << endl;
	
	
	
	return 0;
}
*/
# 결과 실행 시간 메모리 Grader output
1 Incorrect 157 ms 2552 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 809782271.
2 Incorrect 158 ms 2552 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 68749376.
3 Incorrect 158 ms 2492 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 136349820.
4 Incorrect 585 ms 4532 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 650789536.
5 Incorrect 581 ms 4616 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 377506838.
6 Incorrect 600 ms 4584 KB Wrong Answer: Query(738, 741) - expected : 983692994, actual : 61461050.
7 Incorrect 584 ms 4496 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 687550570.
8 Incorrect 583 ms 4524 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 145923264.
9 Incorrect 587 ms 4516 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 18757135.
10 Incorrect 585 ms 4556 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 70590726.