結果

問題 No.1456 Range Xor
ユーザー pengin_2000pengin_2000
提出日時 2021-07-11 05:01:49
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 36 ms / 2,000 ms
コード長 1,442 bytes
コンパイル時間 174 ms
コンパイル使用メモリ 30,068 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-14 20:03:59
合計ジャッジ時間 4,613 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 0 ms
4,380 KB
testcase_03 AC 36 ms
4,376 KB
testcase_04 AC 30 ms
4,376 KB
testcase_05 AC 32 ms
4,376 KB
testcase_06 AC 35 ms
4,380 KB
testcase_07 AC 30 ms
4,380 KB
testcase_08 AC 30 ms
4,384 KB
testcase_09 AC 34 ms
4,376 KB
testcase_10 AC 30 ms
4,376 KB
testcase_11 AC 7 ms
4,376 KB
testcase_12 AC 3 ms
4,376 KB
testcase_13 AC 11 ms
4,376 KB
testcase_14 AC 10 ms
4,380 KB
testcase_15 AC 24 ms
4,380 KB
testcase_16 AC 24 ms
4,380 KB
testcase_17 AC 15 ms
4,376 KB
testcase_18 AC 9 ms
4,380 KB
testcase_19 AC 19 ms
4,376 KB
testcase_20 AC 23 ms
4,380 KB
testcase_21 AC 18 ms
4,376 KB
testcase_22 AC 19 ms
4,376 KB
testcase_23 AC 10 ms
4,380 KB
testcase_24 AC 5 ms
4,376 KB
testcase_25 AC 10 ms
4,380 KB
testcase_26 AC 17 ms
4,380 KB
testcase_27 AC 20 ms
4,376 KB
testcase_28 AC 9 ms
4,376 KB
testcase_29 AC 33 ms
4,380 KB
testcase_30 AC 30 ms
4,380 KB
testcase_31 AC 8 ms
4,380 KB
testcase_32 AC 7 ms
4,380 KB
testcase_33 AC 13 ms
4,380 KB
testcase_34 AC 33 ms
4,376 KB
testcase_35 AC 16 ms
4,380 KB
testcase_36 AC 29 ms
4,376 KB
testcase_37 AC 32 ms
4,376 KB
testcase_38 AC 5 ms
4,380 KB
testcase_39 AC 25 ms
4,380 KB
testcase_40 AC 22 ms
4,376 KB
testcase_41 AC 1 ms
4,376 KB
testcase_42 AC 4 ms
4,376 KB
testcase_43 AC 1 ms
4,380 KB
testcase_44 AC 1 ms
4,380 KB
testcase_45 AC 1 ms
4,376 KB
testcase_46 AC 1 ms
4,384 KB
testcase_47 AC 1 ms
4,376 KB
testcase_48 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
int h[100005], l;
int comp_h(int a, int b)
{
	if (h[a] > h[b])
		return 1;
	else
		return -1;
}
void swap_h(int a, int b)
{
	int f = h[a];
	h[a] = h[b];
	h[b] = f;
	return;
}
void push(int ne)
{
	h[l] = ne;
	int p = l;
	l++;
	for (; p > 0; p = (p - 1) / 2)
		if (comp_h((p - 1) / 2, p) > 0)
			swap_h((p - 1) / 2, p);
	return;
}
int pop()
{
	l--;
	swap_h(0, l);
	int p = 0;
	for (;;)
	{
		if (2 * p + 2 < l)
		{
			if (comp_h(2 * p + 1, 2 * p + 2) > 0)
			{
				if (comp_h(p, 2 * p + 2) > 0)
					swap_h(p, 2 * p + 2);
				p = 2 * p + 2;
			}
			else
			{
				if (comp_h(p, 2 * p + 1) > 0)
					swap_h(p, 2 * p + 1);
				p = 2 * p + 1;
			}
		}
		else if (2 * p + 1 < l)
		{
			if (comp_h(p, 2 * p + 1) > 0)
				swap_h(p, 2 * p + 1);
			p = 2 * p + 1;
		}
		else
			break;
	}
	return h[l];
}
int main()
{
	int n, k;
	scanf("%d %d", &n, &k);
	int i;
	int a[100005];
	for (i = 0; i < n; i++)
		scanf("%d", &a[i]);
	int b[100005];
	b[0] = 0;
	for (i = 0; i < n; i++)
		b[i + 1] = (b[i] ^ a[i]);
	l = 0;
	for (i = 0; i <= n; i++)
		push(b[i]);
	for (i = 0; i <= n; i++)
		b[i] = pop();
	int min, mid, max;
	b[n + 1] = -1;
	for (i = 0; i < n; i++)
	{
		min = -1;
		max = n + 1;
		while (max - min > 1)
		{
			mid = (max + min) / 2;
			if (b[mid] < (k ^ b[i]))
				min = mid;
			else
				max = mid;
		}
		if (i == max)
			max++;
		if ((b[i] ^ b[max]) == k)
		{
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}
0