結果

問題 No.1072 A Nice XOR Pair
ユーザー NagisaNagisa
提出日時 2020-06-06 11:07:19
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 319 ms / 2,000 ms
コード長 456 bytes
コンパイル時間 77 ms
コンパイル使用メモリ 10,776 KB
実行使用メモリ 31,644 KB
最終ジャッジ日時 2023-08-24 23:24:04
合計ジャッジ時間 2,281 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,440 KB
testcase_01 AC 19 ms
8,580 KB
testcase_02 AC 18 ms
8,440 KB
testcase_03 AC 18 ms
8,600 KB
testcase_04 AC 18 ms
8,508 KB
testcase_05 AC 18 ms
8,496 KB
testcase_06 AC 21 ms
8,692 KB
testcase_07 AC 319 ms
31,644 KB
testcase_08 AC 133 ms
16,404 KB
testcase_09 AC 133 ms
16,256 KB
testcase_10 AC 134 ms
16,240 KB
testcase_11 AC 178 ms
20,144 KB
testcase_12 AC 188 ms
31,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import Counter
def input():
    return sys.stdin.readline()[:-1]
def main():
    N, X = map(int,input().split())
    A = [int(input()) for _ in range(N)]
    C = Counter(A)
    ans = 0
    if X != 0:
        for e in C:
            if e^X in C:
                ans += C[e]*C[e^X]
                C[e^X] = 0
    else:
        for e in C:
            ans += (C[e]*(C[e]-1))//2
    print(ans)
if __name__ == '__main__':
    main()
0