結果

問題 No.1805 Approaching Many Typhoon
ユーザー yudedakoyudedako
提出日時 2022-01-24 22:47:12
言語 Scala(Beta)
(3.4.0)
結果
AC  
実行時間 1,011 ms / 2,000 ms
コード長 897 bytes
コンパイル時間 9,971 ms
コンパイル使用メモリ 256,316 KB
実行使用メモリ 63,112 KB
最終ジャッジ日時 2023-08-21 14:03:34
合計ジャッジ時間 52,003 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 948 ms
62,408 KB
testcase_01 AC 941 ms
62,392 KB
testcase_02 AC 962 ms
62,316 KB
testcase_03 AC 950 ms
62,536 KB
testcase_04 AC 957 ms
62,748 KB
testcase_05 AC 955 ms
62,212 KB
testcase_06 AC 958 ms
62,304 KB
testcase_07 AC 946 ms
62,276 KB
testcase_08 AC 949 ms
62,428 KB
testcase_09 AC 942 ms
62,532 KB
testcase_10 AC 944 ms
62,380 KB
testcase_11 AC 946 ms
62,080 KB
testcase_12 AC 946 ms
62,220 KB
testcase_13 AC 959 ms
62,520 KB
testcase_14 AC 944 ms
62,668 KB
testcase_15 AC 952 ms
62,024 KB
testcase_16 AC 949 ms
62,372 KB
testcase_17 AC 953 ms
62,588 KB
testcase_18 AC 951 ms
62,120 KB
testcase_19 AC 958 ms
61,988 KB
testcase_20 AC 949 ms
62,556 KB
testcase_21 AC 956 ms
62,528 KB
testcase_22 AC 956 ms
62,396 KB
testcase_23 AC 947 ms
62,472 KB
testcase_24 AC 942 ms
62,184 KB
testcase_25 AC 956 ms
62,540 KB
testcase_26 AC 955 ms
62,412 KB
testcase_27 AC 947 ms
62,556 KB
testcase_28 AC 996 ms
62,720 KB
testcase_29 AC 999 ms
62,756 KB
testcase_30 AC 1,011 ms
62,444 KB
testcase_31 AC 1,009 ms
63,112 KB
testcase_32 AC 964 ms
62,592 KB
testcase_33 AC 964 ms
62,456 KB
testcase_34 AC 985 ms
62,684 KB
testcase_35 AC 989 ms
62,412 KB
testcase_36 AC 994 ms
62,528 KB
testcase_37 AC 950 ms
62,736 KB
testcase_38 AC 956 ms
62,964 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
    graph(t) ::= f
  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