結果

問題 No.1576 織姫と彦星
ユーザー yuruhiya
提出日時 2021-07-03 09:16:13
言語 Crystal
(1.14.0)
結果
TLE  
実行時間 -
コード長 368 bytes
コンパイル時間 11,246 ms
コンパイル使用メモリ 295,588 KB
実行使用メモリ 61,184 KB
最終ジャッジ日時 2024-06-30 01:56:29
合計ジャッジ時間 15,095 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 2 TLE * 1 -- * 51
権限があれば一括ダウンロードができます

ソースコード

diff #

n = read_line.to_i
s, t = read_line.split.map(&.to_i)
a = read_line.split.map(&.to_i) + [s, t]
hash = a.zip(0..).to_h
que = Deque{n}
dist = [nil.as(Int32?)] * (n + 2)
dist[n] = -1
while i = que.shift?
  d = dist[i].not_nil!
  puts(d) + exit if i == n + 1
	a.each_with_index do |x, j|
		if (a[i] ^ x).popcount == 1
			dist[j] = d + 1
			que << j
		end
	end
end
puts -1
0