結果

問題 No.2061 XOR Sort
ユーザー 👑 ygussanyygussany
提出日時 2022-08-21 18:29:29
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 985 bytes
コンパイル時間 380 ms
コンパイル使用メモリ 29,920 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-07-31 12:54:20
合計ジャッジ時間 2,621 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 0 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 0 ms
4,376 KB
testcase_06 AC 0 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 0 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 0 ms
4,376 KB
testcase_13 AC 0 ms
4,376 KB
testcase_14 AC 25 ms
4,380 KB
testcase_15 AC 26 ms
4,376 KB
testcase_16 AC 52 ms
4,380 KB
testcase_17 AC 34 ms
4,380 KB
testcase_18 AC 34 ms
4,376 KB
testcase_19 AC 34 ms
4,376 KB
testcase_20 AC 5 ms
4,380 KB
testcase_21 AC 15 ms
4,376 KB
testcase_22 AC 26 ms
4,376 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 53 ms
4,380 KB
testcase_25 AC 53 ms
4,380 KB
testcase_26 AC 53 ms
4,380 KB
testcase_27 AC 54 ms
4,380 KB
testcase_28 AC 53 ms
4,376 KB
testcase_29 AC 15 ms
4,376 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 0 ms
4,376 KB
testcase_34 AC 1 ms
4,380 KB
testcase_35 AC 1 ms
4,376 KB
testcase_36 AC 0 ms
4,380 KB
testcase_37 AC 1 ms
4,380 KB
testcase_38 AC 1 ms
4,376 KB
testcase_39 AC 1 ms
4,376 KB
testcase_40 AC 0 ms
4,376 KB
testcase_41 AC 0 ms
4,380 KB
testcase_42 AC 1 ms
4,380 KB
testcase_43 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

const int Mod = 998244353;

void merge_sort(int n, int x[])
{
	static int y[200001] = {};
	if (n <= 1) return;
	merge_sort(n / 2, &(x[0]));
	merge_sort((n + 1) / 2, &(x[n/2]));
	
	int i, p, q;
	for (i = 0, p = 0, q = n / 2; i < n; i++) {
		if (p >= n / 2) y[i] = x[q++];
		else if (q >= n) y[i] = x[p++];
		else y[i] = (x[p] < x[q])? x[p++]: x[q++];
	}
	for (i = 0; i < n; i++) x[i] = y[i];
}

int main()
{
	int i, N, A[200001];
	scanf("%d", &N);
	for (i = 0; i < N; i++) scanf("%d", &(A[i]));
	merge_sort(N, A);
	
	int n = 0, B[200001];
	for (i = 1, B[n++] = A[0]; i < N; i++) if (B[n-1] != A[i]) B[n++] = A[i];
	
	int j, bit[31], flag[31] = {};
	for (i = 1, bit[0] = 1; i <= 30; i++) bit[i] = bit[i-1] << 1;
	for (i = 0; i < n - 1; i++) {
		for (j = 30; j >= 0; j--) if ((B[i] & bit[j]) != (B[i+1] & bit[j])) break;
		flag[j] = 1;
	}
	
	int ans = 1;
	for (i = 0; i <= 30; i++) if (flag[i] != 0) ans <<= 1;
	printf("%d\n", ans % Mod);
	fflush(stdout);
	return 0;
}
0