結果

問題 No.240 ナイト散歩
ユーザー くわいくわい
提出日時 2015-09-21 00:51:06
言語 Scala(Beta)
(3.3.1)
結果
AC  
実行時間 1,005 ms / 2,000 ms
コード長 781 bytes
コンパイル時間 8,506 ms
コンパイル使用メモリ 258,836 KB
実行使用メモリ 63,956 KB
最終ジャッジ日時 2023-08-10 12:00:09
合計ジャッジ時間 44,744 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 973 ms
62,956 KB
testcase_01 AC 989 ms
63,260 KB
testcase_02 AC 979 ms
62,992 KB
testcase_03 AC 982 ms
62,952 KB
testcase_04 AC 980 ms
63,236 KB
testcase_05 AC 980 ms
62,960 KB
testcase_06 AC 973 ms
63,112 KB
testcase_07 AC 965 ms
62,844 KB
testcase_08 AC 998 ms
63,216 KB
testcase_09 AC 1,004 ms
63,152 KB
testcase_10 AC 990 ms
62,952 KB
testcase_11 AC 975 ms
63,152 KB
testcase_12 AC 972 ms
63,956 KB
testcase_13 AC 1,005 ms
62,988 KB
testcase_14 AC 1,004 ms
62,928 KB
testcase_15 AC 972 ms
63,100 KB
testcase_16 AC 982 ms
63,032 KB
testcase_17 AC 974 ms
63,012 KB
testcase_18 AC 1,005 ms
63,256 KB
testcase_19 AC 1,002 ms
63,308 KB
testcase_20 AC 976 ms
62,980 KB
testcase_21 AC 981 ms
63,148 KB
testcase_22 AC 976 ms
63,064 KB
testcase_23 AC 986 ms
62,948 KB
testcase_24 AC 973 ms
63,120 KB
testcase_25 AC 998 ms
63,140 KB
testcase_26 AC 967 ms
63,192 KB
testcase_27 AC 970 ms
63,048 KB
testcase_28 AC 973 ms
63,296 KB
testcase_29 AC 977 ms
62,940 KB
testcase_30 AC 969 ms
62,964 KB
testcase_31 AC 969 ms
63,548 KB
testcase_32 AC 998 ms
62,960 KB
testcase_33 AC 981 ms
63,080 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner

object Problem240 {
  def main(args: Array[String]) = {
    val sc = new Scanner(System.in)
    val x = sc.nextInt()
    val y = sc.nextInt()

    val result = proc(x, y, 3)
    println(result)
  }

  def proc(targetX: Int, targetY: Int, stepLimit: Int): String = {
    val dxy = List((-2, -1), (-2, 1), (-1, -2), (-1, 2), (1, -2), (1, 2), (2, -1), (2, 1))
    var found = false

    def procR(x: Int, y: Int, steps: Int): Unit = {
      if (x == targetX && y == targetY) {
        found = true
        return
      }

      if (steps == stepLimit || found) {
        return
      }

      for ((dx, dy) <- dxy) {
        procR(x + dx, y + dy, steps + 1)
      }
    }

    procR(0, 0, 0)

    if (found) {
      "YES"
    } else {
      "NO"
    }
  }
}
0