Submission #386816

# Submission time Handle Problem Language Result Execution time Memory
386816 2021-04-07T11:12:15 Z saarang123 Secret (JOI14_secret) C++17
0 / 100
506 ms 8320 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 136 ms 4460 KB Wrong Answer [1]
2 Incorrect 135 ms 4460 KB Wrong Answer [1]
3 Incorrect 134 ms 4608 KB Wrong Answer [1]
4 Incorrect 496 ms 8220 KB Wrong Answer [1]
5 Incorrect 497 ms 8300 KB Wrong Answer [1]
6 Incorrect 499 ms 8172 KB Wrong Answer [1]
7 Incorrect 498 ms 8320 KB Wrong Answer [1]
8 Incorrect 501 ms 8300 KB Wrong Answer [1]
9 Incorrect 506 ms 8216 KB Wrong Answer [1]
10 Incorrect 501 ms 8300 KB Wrong Answer [1]