結果
問題 |
No.43 野球の試合
|
ユーザー |
|
提出日時 | 2017-06-15 13:02:33 |
言語 | Ruby (3.4.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 606 bytes |
コンパイル時間 | 39 ms |
コンパイル使用メモリ | 7,424 KB |
実行使用メモリ | 13,880 KB |
最終ジャッジ日時 | 2024-09-25 02:09:46 |
合計ジャッジ時間 | 7,070 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 2 TLE * 1 -- * 4 |
コンパイルメッセージ
Syntax OK
ソースコード
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)