結果

問題 No.2397 ω冪
ユーザー magurofly
提出日時 2023-07-29 01:09:34
言語 Ruby
(3.4.1)
結果
WA  
実行時間 -
コード長 507 bytes
コンパイル時間 223 ms
コンパイル使用メモリ 7,296 KB
実行使用メモリ 21,248 KB
最終ジャッジ日時 2024-10-07 00:50:21
合計ジャッジ時間 9,186 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17 WA * 24
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def str_to_ord(s)
	n = s.size
	indices = [0] + (0 ... n).filter { |i| s[i] == "1" }
	a = indices.each_cons(2).map { |l, r| int_to_ord(r - l) }
	a.sort!
	a.reverse!
	a.flatten
end

def int_to_ord(n, d = 0)
	if n == 0
		return [d]
	end
	xs = []
	while n > 0
		b = 0
		while n & 1 == 0
			b += 1
			n >>= 1
		end
		xs << b
		n >>= 1
	end
	ys = xs.map { |m| int_to_ord(m, d + 1) }
	ys.sort!
	ys.reverse!
	ys.flatten
end

N = str_to_ord(gets.chomp)
M = str_to_ord(gets.chomp)

puts ((N <=> M) < 0) ? "Yes" : "No"
0