結果

問題 No.2061 XOR Sort
ユーザー square1001square1001
提出日時 2022-08-26 22:38:19
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 951 bytes
コンパイル時間 212 ms
コンパイル使用メモリ 33,160 KB
実行使用メモリ 4,652 KB
最終ジャッジ日時 2023-08-04 02:11:22
合計ジャッジ時間 2,079 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <cstdio>

int readint() {
	int res = 0;
	char c = getchar_unlocked();
	while ('0' <= c && c <= '9') {
		res = res * 10 + int(c - '0');
		c = getchar_unlocked();
	}
	return res;
}

int N, A[200000], tmp[200000], cnt[32800];
int main() {
	// step #1. input & radix sort
	N = readint();
	for (int i = 0; i < N; i++) {
		A[i] = readint();
		cnt[(A[i] & 32767) + 1] += 1;
	}
	for (int i = 0; i < 32768; i++) cnt[i + 1] += cnt[i];
	for (int i = 0; i < N; i++) tmp[cnt[A[i] & 32767]++] = A[i];
	for (int i = 0; i < 32769; i++) cnt[i] = 0;
	for (int i = 0; i < N; i++) cnt[(tmp[i] >> 15) + 1] += 1;
	for (int i = 0; i < 32768; i++) cnt[i + 1] += cnt[i];
	for (int i = 0; i < N; i++) A[cnt[tmp[i] >> 15]++] = tmp[i];
	// step #2. compute the answer
	int bit = 0;
	for (int i = 0; i < N - 1; i++) {
		if (A[i] != A[i + 1]) {
			bit |= 1 << __builtin_clz(A[i] ^ A[i + 1]);
		}
	}
	printf("%d\n", (1 << __builtin_popcount(bit)) % 998244353);
	return 0;
}
0