結果

問題 No.1576 織姫と彦星
ユーザー yuruhiyayuruhiya
提出日時 2021-07-03 09:16:13
言語 Crystal
(1.11.2)
結果
TLE  
実行時間 -
コード長 368 bytes
コンパイル時間 19,424 ms
コンパイル使用メモリ 255,216 KB
実行使用メモリ 8,752 KB
最終ジャッジ日時 2023-09-12 13:49:46
合計ジャッジ時間 22,605 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,380 KB
testcase_01 AC 3 ms
4,428 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,456 KB
testcase_04 AC 2 ms
4,392 KB
testcase_05 AC 2 ms
4,444 KB
testcase_06 AC 3 ms
4,516 KB
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 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
権限があれば一括ダウンロードができます

ソースコード

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