結果

問題 No.707 書道
ユーザー fukafukatanifukafukatani
提出日時 2021-06-24 20:22:59
言語 Scala(Beta)
(3.4.0)
結果
AC  
実行時間 1,105 ms / 2,000 ms
コード長 631 bytes
コンパイル時間 12,546 ms
コンパイル使用メモリ 256,656 KB
実行使用メモリ 64,152 KB
最終ジャッジ日時 2023-09-07 13:26:34
合計ジャッジ時間 24,163 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 958 ms
63,616 KB
testcase_01 AC 985 ms
63,648 KB
testcase_02 AC 1,015 ms
63,980 KB
testcase_03 AC 969 ms
63,800 KB
testcase_04 AC 972 ms
63,544 KB
testcase_05 AC 1,077 ms
63,872 KB
testcase_06 AC 1,105 ms
64,092 KB
testcase_07 AC 1,104 ms
64,152 KB
testcase_08 AC 1,007 ms
63,832 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val h, w = sc.nextInt
  val poses = (0 until h).map({ _ =>
    val s = sc.next
    (0 until w).filter(s(_) == '1')
  })
  Console.err.println(poses(0).mkString(" "))
  val cands = (1 to w).map((0, _)) ++ (1 to w).map((h + 1, _)) ++ (1 to h).map((_, 0)) ++ (1 to h).map((_, w + 1))
  val ans = cands.map({
    case (sy, sx) => (0 until h).map({
      cy =>
        poses(cy).map({
          cx =>
            math.sqrt(((cx + 1 - sx) * (cx + 1 - sx) + (cy + 1 - sy) * (cy + 1 - sy)).toFloat)
        }).sum
    }).sum
  }).min
  println(ans)
}
0