結果
| 問題 |
No.1805 Approaching Many Typhoon
|
| ユーザー |
|
| 提出日時 | 2022-01-24 22:45:10 |
| 言語 | Scala(Beta) (3.6.2) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 846 bytes |
| コンパイル時間 | 15,836 ms |
| コンパイル使用メモリ | 250,952 KB |
| 実行使用メモリ | 63,984 KB |
| 最終ジャッジ日時 | 2024-12-15 02:12:35 |
| 合計ジャッジ時間 | 55,766 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 24 WA * 8 RE * 3 |
ソースコード
import scala.collection.mutable
import scala.io.StdIn.*
import scala.math.min
@main def main =
val Array(n, m) = readLine().split(' ').map(_.toInt)
val Array(s, g) = readLine().split(' ').map(_.toInt - 1)
val edges = Array.fill(m){
val Array(f, t) = readLine().split(' ').map(_.toInt - 1)
(f, t)
}
val graph = Array.fill(n){Nil: List[Int]}
for (f, t) <- edges do
graph(f) ::= t
val u = readLine().toInt
val closed = readLine().split(' ').map(_.toInt - 1)
val visit = Array.fill(n){false}
val stack = mutable.ArrayDeque[Int]().addOne(s)
visit(s) = true
for i <- closed do
visit(i) = true
while stack.nonEmpty do
val current = stack.removeLast()
for next <- graph(current) do
if !visit(next) then
visit(next) = true
stack.addOne(next)
println(if (visit(g)) "Yes" else "No")