結果
問題 |
No.1072 A Nice XOR Pair
|
ユーザー |
|
提出日時 | 2021-11-05 16:39:53 |
言語 | Ruby (3.4.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 503 bytes |
コンパイル時間 | 104 ms |
コンパイル使用メモリ | 7,552 KB |
実行使用メモリ | 30,624 KB |
最終ジャッジ日時 | 2024-11-06 07:19:03 |
合計ジャッジ時間 | 4,568 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 5 TLE * 1 -- * 5 |
コンパイルメッセージ
Syntax OK
ソースコード
N, X = gets.split(" ").map{|s| s.to_i} a = [] N.times { a << gets.to_i } a.sort! used = [] cnt = 0 a.uniq.each {|y| next if used.include?(y) ymin = a.bsearch_index{|i| i >= y} ymax = a.bsearch_index{|i| i > y} ymax = N if not ymax ycnt = ymax - ymin z = y ^ X if z == y then cnt += ycnt * (ycnt - 1) / 2 next end zmin = a.bsearch_index{|i| i >= z} next if not zmin used << z zmax = a.bsearch_index{|i| i > z} zmax = N if not zmax zcnt = zmax - zmin cnt += ycnt * zcnt } puts cnt