結果

問題 No.1072 A Nice XOR Pair
ユーザー 6soukiti296soukiti29
提出日時 2020-06-09 01:59:36
言語 Nim
(2.0.2)
結果
WA  
実行時間 -
コード長 594 bytes
コンパイル時間 4,448 ms
コンパイル使用メモリ 68,944 KB
実行使用メモリ 10,400 KB
最終ジャッジ日時 2023-08-28 10:06:16
合計ジャッジ時間 4,966 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 RE -
testcase_08 AC 93 ms
7,724 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 127 ms
8,740 KB
testcase_12 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sequtils,strutils,algorithm
var
    N, X : int64
    A : seq[int64]
    B : seq[int64]
    ans : int64
    f :array[100010, int64]

(N, X) = stdin.readline.split.map(parseBiggestInt)

for i in 1..N:
    A.add(stdin.readline.parseBiggestInt)

A.sort(cmp)

for i,a in A:
    if B.len == 0 or B[^1] != a:
         B.add(a)
    f[B.high] += 1
for i,a in B:
    if X == 0:
        ans += f[i] * (f[i] - 1) div 2
    var k : int64 = (X xor a)
    var j = B.lowerbound(k)

    if j > B.high or B[j] != k:
        continue
    ans += f[j] * f[i]
if X > 0:
    echo (ans div 2)
else:
    echo ans
0