結果

問題 No.1805 Approaching Many Typhoon
ユーザー yudedakoyudedako
提出日時 2022-01-24 22:46:24
言語 Scala(Beta)
(3.4.0)
結果
WA  
実行時間 -
コード長 878 bytes
コンパイル時間 10,232 ms
コンパイル使用メモリ 256,608 KB
実行使用メモリ 63,512 KB
最終ジャッジ日時 2023-08-21 14:02:16
合計ジャッジ時間 51,039 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 961 ms
62,564 KB
testcase_01 AC 935 ms
62,252 KB
testcase_02 AC 928 ms
62,500 KB
testcase_03 AC 923 ms
62,600 KB
testcase_04 WA -
testcase_05 AC 936 ms
62,536 KB
testcase_06 AC 955 ms
62,228 KB
testcase_07 AC 949 ms
62,544 KB
testcase_08 AC 919 ms
62,456 KB
testcase_09 WA -
testcase_10 AC 936 ms
62,360 KB
testcase_11 AC 920 ms
62,468 KB
testcase_12 WA -
testcase_13 AC 925 ms
62,612 KB
testcase_14 AC 943 ms
62,396 KB
testcase_15 WA -
testcase_16 AC 942 ms
62,460 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 947 ms
62,716 KB
testcase_21 AC 943 ms
62,344 KB
testcase_22 AC 931 ms
62,144 KB
testcase_23 AC 948 ms
62,448 KB
testcase_24 AC 969 ms
62,468 KB
testcase_25 AC 934 ms
62,468 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 1,006 ms
62,320 KB
testcase_29 AC 1,015 ms
62,704 KB
testcase_30 AC 1,016 ms
62,532 KB
testcase_31 AC 1,012 ms
62,944 KB
testcase_32 AC 954 ms
62,548 KB
testcase_33 AC 949 ms
62,356 KB
testcase_34 AC 969 ms
62,700 KB
testcase_35 AC 990 ms
62,504 KB
testcase_36 AC 1,015 ms
62,860 KB
testcase_37 AC 939 ms
62,208 KB
testcase_38 AC 929 ms
62,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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")
0