結果

問題 No.2061 XOR Sort
ユーザー square1001square1001
提出日時 2022-08-26 22:35:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 937 bytes
コンパイル時間 209 ms
コンパイル使用メモリ 34,304 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-22 00:40:59
合計ジャッジ時間 1,656 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 3 ms
6,940 KB
testcase_21 AC 4 ms
6,944 KB
testcase_22 WA -
testcase_23 AC 2 ms
6,940 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 4 ms
6,940 KB
testcase_30 AC 2 ms
6,940 KB
testcase_31 AC 2 ms
6,940 KB
testcase_32 AC 2 ms
6,944 KB
testcase_33 AC 2 ms
6,940 KB
testcase_34 AC 2 ms
6,944 KB
testcase_35 AC 1 ms
6,944 KB
testcase_36 AC 2 ms
6,940 KB
testcase_37 AC 2 ms
6,944 KB
testcase_38 AC 2 ms
6,940 KB
testcase_39 AC 2 ms
6,940 KB
testcase_40 AC 1 ms
6,940 KB
testcase_41 AC 2 ms
6,940 KB
testcase_42 AC 1 ms
6,940 KB
testcase_43 AC 2 ms
6,944 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));
	return 0;
}
0