結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー 👑 horiesinitihoriesiniti
提出日時 2017-10-22 17:33:01
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 608 bytes
コンパイル時間 41 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 31,232 KB
最終ジャッジ日時 2024-05-01 10:17:40
合計ジャッジ時間 7,404 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 91 ms
12,288 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

require 'set'
def f(e)
	e2=e
	(e.size..14).each{
		e2="0"+e2
	}
	return e2
end

gets.to_i
as=gets.split.map{|e| e.to_i.to_s(2)}
bs=as.map{|e|
	f(e)
}.sort.reverse.uniq
dp=Hash.new(0)
dp[0]=1
p2=0

(0..14).each{|p1|
	dp2=Hash.new(0)
	
	while bs.size>p2 && bs[p2][p1]=="1"
		dp.keys.each{|e1|
			e2=bs[p2]
			e2=(e1^(e2.to_i(2))).to_s(2)
			e2=f(e2)
			(0..(p1-1)).each{|i|
				e2[i]="0"
			}
			dp2[e2.to_i(2)]+=dp[e1]
			e3=f(e1.to_s(2))
			(0..(p1-1)).each{|i|
				e3[i]="0"
			}
			dp2[e3.to_i(2)]+=dp[e1]
		}
		p2+=1
	end
	if dp2.empty? == false
		dp=dp2
	end
}
ans=0
dp.values.each{|e|
	ans+=e
}
puts ans
0