結果
問題 | No.1072 A Nice XOR Pair |
ユーザー | nephrologist |
提出日時 | 2020-06-08 19:28:44 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 773 bytes |
コンパイル時間 | 402 ms |
コンパイル使用メモリ | 10,872 KB |
実行使用メモリ | 45,104 KB |
最終ジャッジ日時 | 2023-08-27 00:20:02 |
合計ジャッジ時間 | 5,889 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 19 ms
8,512 KB |
testcase_01 | AC | 18 ms
8,456 KB |
testcase_02 | AC | 18 ms
8,564 KB |
testcase_03 | AC | 18 ms
8,612 KB |
testcase_04 | AC | 18 ms
8,640 KB |
testcase_05 | WA | - |
testcase_06 | AC | 25 ms
8,860 KB |
testcase_07 | AC | 759 ms
45,104 KB |
testcase_08 | WA | - |
testcase_09 | AC | 424 ms
8,464 KB |
testcase_10 | AC | 417 ms
8,600 KB |
testcase_11 | WA | - |
testcase_12 | AC | 766 ms
44,928 KB |
ソースコード
# a^b==c は a^b^c==0 from collections import defaultdict n, x = map(int, input().split()) ans = 0 if x == 0: jisho1 = defaultdict(int) for i in range(n): a = int(input()) jisho1[a] += 1 zeronum = jisho1[0] if zeronum: ans += zeronum * (n - zeronum) ans += zeronum * (zeronum - 1) // 2 for key, val in jisho1.items(): if key == 0: continue ans += val * (val - 1) // 2 else: jisho1 = defaultdict(int) jisho2 = defaultdict(int) for i in range(n): a = int(input()) jisho1[a] += 1 jisho2[a ^ x] += 1 for key, val1 in jisho1.items(): if key == 0: continue val2 = jisho2[key] ans += val1 * val2 ans //= 2 print(ans)