結果
問題 | No.1868 Teleporting Cyanmond |
ユーザー |
![]() |
提出日時 | 2022-03-11 21:35:28 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 1,148 ms / 2,000 ms |
コード長 | 704 bytes |
コンパイル時間 | 2,608 ms |
コンパイル使用メモリ | 225,808 KB |
実行使用メモリ | 8,032 KB |
最終ジャッジ日時 | 2024-06-22 14:34:28 |
合計ジャッジ時間 | 8,203 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
ソースコード
import std; struct S { int pos, cnt; } void main() { int N; readf("%d\n", N); auto R = readln.chomp.split.to!(int[]); int res; auto seen = new bool[](N); seen[0] = true; --N; R[] -= 1; auto heap = new BinaryHeap!(Array!S, "a.cnt == b.cnt ? a.pos < b.pos : a.cnt > b.cnt")(); heap.insert(S(0, 0)); while (!heap.empty) { auto f = heap.front; heap.popFront; if (f.pos == N) { res = f.cnt; break; } foreach (i; f.pos .. R[f.pos]+1) { if (!seen[i]) { heap.insert(S(i, f.cnt+1)); seen[i] = true; } } } res.writeln; }