結果
問題 | No.43 野球の試合 |
ユーザー |
![]() |
提出日時 | 2016-10-27 23:19:21 |
言語 | Scala(Beta) (3.6.2) |
結果 |
WA
|
実行時間 | - |
コード長 | 828 bytes |
コンパイル時間 | 7,829 ms |
コンパイル使用メモリ | 259,624 KB |
実行使用メモリ | 64,512 KB |
最終ジャッジ日時 | 2024-06-29 19:43:08 |
合計ジャッジ時間 | 18,163 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 6 WA * 1 |
ソースコード
import scala.io.StdInobject Main {def rec(idx: Int, n: Int, s: Array[Array[Char]]): Int = {if (idx == n * n) {val winCount = s.map { (ss) =>ss.filter(_ == 'o').size}var rank = 1for (i <- (0 to n).reverse) {if (winCount(0) == i) return rankif (winCount.filter(_ == i).size != 0) rank += 1}}val x = idx % nval y = idx / nif (s(y)(x) == '-') {s(y)(x) = 'o's(x)(y) = 'x'val res1 = rec(idx + 1, n, s)s(y)(x) = 'x's(x)(y) = 'o'val res2 = rec(idx + 1, n, s)return Math.min(res1, res2)} else {return rec(idx + 1, n, s)}}def main(args: Array[String]): Unit = {val n = StdIn.readIntval s = Array.fill(n)(StdIn.readLine.toArray)println(rec(0, n, s))}}