結果

問題 No.43 野球の試合
ユーザー letrangerjpletrangerjp
提出日時 2017-06-15 13:02:33
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 606 bytes
コンパイル時間 222 ms
コンパイル使用メモリ 11,916 KB
実行使用メモリ 21,816 KB
最終ジャッジ日時 2023-10-25 06:46:59
合計ジャッジ時間 7,333 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
20,508 KB
testcase_01 AC 89 ms
16,160 KB
testcase_02 AC 83 ms
16,160 KB
testcase_03 AC 83 ms
16,160 KB
testcase_04 AC 82 ms
16,160 KB
testcase_05 AC 83 ms
16,160 KB
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
S = N.times.map{
  gets[0,N]
}
res = N.times.map{[nil]*N}
S.each_with_index{|s, i|
  s.chars.each_with_index{|c, ii|
    res[i][ii] = c
  }
}
N.times{|x|
  if res[0][x] == ?-
    res[0][x] = ?o
    res[x][0] = ?x
  end
}


def f(res)
  if !res.any?{|a|a.any?{|c|c == ?-}}
    win = res[0].count(?o)
    return 1 + res.map{|a|a.count(?o)}.sort_by{|o|-o}.uniq.index(win)
  end
  N.times.map{|y|
    N.times.map{|x|
      next 9e9 if res[y][x] != ?-
      res[y][x] = ?o
      res[x][y] = ?x
      f(res).tap{
        res[y][x] = ?-
        res[x][y] = ?-
      }
    }.min
  }.min
end
p f(res)
0