結果

問題 No.240 ナイト散歩
ユーザー ともきともき
提出日時 2015-07-10 23:05:53
言語 Scala(Beta)
(3.4.0)
結果
AC  
実行時間 1,089 ms / 2,000 ms
コード長 912 bytes
コンパイル時間 12,460 ms
コンパイル使用メモリ 261,748 KB
実行使用メモリ 64,044 KB
最終ジャッジ日時 2023-09-11 11:46:12
合計ジャッジ時間 51,180 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,049 ms
63,456 KB
testcase_01 AC 1,052 ms
63,488 KB
testcase_02 AC 1,039 ms
63,720 KB
testcase_03 AC 1,053 ms
63,692 KB
testcase_04 AC 1,050 ms
63,764 KB
testcase_05 AC 1,048 ms
63,552 KB
testcase_06 AC 1,047 ms
63,948 KB
testcase_07 AC 1,059 ms
63,736 KB
testcase_08 AC 1,062 ms
63,560 KB
testcase_09 AC 1,048 ms
63,572 KB
testcase_10 AC 1,089 ms
63,564 KB
testcase_11 AC 1,059 ms
63,464 KB
testcase_12 AC 1,061 ms
63,704 KB
testcase_13 AC 1,047 ms
63,948 KB
testcase_14 AC 1,035 ms
63,900 KB
testcase_15 AC 1,062 ms
63,596 KB
testcase_16 AC 1,057 ms
63,548 KB
testcase_17 AC 1,052 ms
63,808 KB
testcase_18 AC 1,079 ms
63,600 KB
testcase_19 AC 1,050 ms
63,524 KB
testcase_20 AC 1,060 ms
63,780 KB
testcase_21 AC 1,047 ms
63,452 KB
testcase_22 AC 1,058 ms
63,564 KB
testcase_23 AC 1,058 ms
63,740 KB
testcase_24 AC 1,052 ms
63,660 KB
testcase_25 AC 1,047 ms
63,676 KB
testcase_26 AC 1,066 ms
63,472 KB
testcase_27 AC 1,048 ms
63,900 KB
testcase_28 AC 1,048 ms
63,484 KB
testcase_29 AC 1,065 ms
63,740 KB
testcase_30 AC 1,062 ms
63,588 KB
testcase_31 AC 1,064 ms
63,476 KB
testcase_32 AC 1,056 ms
63,660 KB
testcase_33 AC 1,057 ms
64,044 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import scala.io.StdIn.readLine
import scala.collection.mutable.PriorityQueue
import scala.annotation.tailrec

// PriorityQueue[Long]()(scala.math.Ordering.Long.reverse)
package Lib {
  object EnRich {
    implicit class AString(val self : String) extends AnyVal {
      def splitToIntArray = self.split(" ").map(_.toInt)
    }
  }
}

import Lib.EnRich._
object Main {
  def go(x : Int, y : Int, k : Int = 3) : Set[(Int,Int)] = {
    if(k == 0) Set((x,y))
    else {
      (for(i <- Vector(-2,-1,1,2);
          j <- Vector(-2,-1,1,2);
          if Math.abs(i) + Math.abs(j) == 3)
       yield (i,j)
      ).map({case (i,j) => go(x+i,y+j,k-1)})
      .fold(Set[(Int,Int)]())(_ ++ _) + ((x,y))
    }
  }
  def main(args : Array[String]) : Unit = {
    val (x,y) = {
      val xy = readLine.splitToIntArray
      (xy(0),xy(1))
    }
    val ans = if(go(0,0,3) contains (x,y)) "YES" else "NO"
    println(ans)
  }
}
0