結果
| 問題 | 
                            No.1805 Approaching Many Typhoon
                             | 
                    
| ユーザー | 
                             | 
                    
| 提出日時 | 2022-01-24 22:46:24 | 
| 言語 | Scala(Beta)  (3.6.2)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 878 bytes | 
| コンパイル時間 | 16,249 ms | 
| コンパイル使用メモリ | 279,708 KB | 
| 実行使用メモリ | 65,380 KB | 
| 最終ジャッジ日時 | 2024-12-15 02:14:20 | 
| 合計ジャッジ時間 | 50,330 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 26 WA * 9 | 
ソースコード
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 = if u > 0 then readLine().split(' ').map(_.toInt - 1) else Array[Int]()
  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")