Submission #386817

# Submission time Handle Problem Language Result Execution time Memory
386817 2021-04-07T11:13:31 Z saarang123 Secret (JOI14_secret) C++17
0 / 100
514 ms 8300 KB
#include <bits/stdc++.h>
#ifndef saarang
#include "secret.h"
#endif
using namespace std;
const int mxn = 1002;
int a[mxn][mxn], n;

#ifdef saarang
int Secret(int x, int y) { return x ^ y; }
#endif

void fix(int l, int r) {
	int mid = (l + r) >> 1;
	if(r - l <= 1)
		return;
	for(int i = mid + 1; i <= r; i++)
		a[mid][i] = Secret(a[mid][i - 1], a[i][i]);
	for(int i = mid - 1; i >= l; i--)
		a[i][mid] = Secret(a[i][i], a[i + 1][mid]);
	fix(l, mid);
	fix(mid + 1, r);
}

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

int answer(int l, int r, int ql, int qr) {
	int mid = (l + r) >> 1;
	if(ql > mid)
		return answer(mid + 1, r, ql, qr);
	else if(qr <= mid)
		return answer(l, mid, ql, qr);
	return Secret(a[ql][mid], a[mid + 1][qr]);
}

int Query(int L, int R) {
    if(L == R)
        return a[L][L];
    if(L == R - 1)
        return Secret(a[L][L], a[R][R]);
    return answer(0, n - 1, L, R);
}
# Verdict Execution time Memory Grader output
1 Incorrect 135 ms 4460 KB Wrong Answer [1]
2 Incorrect 133 ms 4460 KB Wrong Answer [1]
3 Incorrect 144 ms 4604 KB Wrong Answer [1]
4 Incorrect 494 ms 8216 KB Wrong Answer [1]
5 Incorrect 502 ms 8240 KB Wrong Answer [1]
6 Incorrect 509 ms 8300 KB Wrong Answer [1]
7 Incorrect 514 ms 8300 KB Wrong Answer [1]
8 Incorrect 510 ms 8300 KB Wrong Answer [1]
9 Incorrect 498 ms 8172 KB Wrong Answer [1]
10 Incorrect 501 ms 8300 KB Wrong Answer [1]