結果

問題 No.43 野球の試合
ユーザー letrangerjpletrangerjp
提出日時 2017-06-15 12:44:55
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 478 bytes
コンパイル時間 87 ms
コンパイル使用メモリ 12,016 KB
実行使用メモリ 16,256 KB
最終ジャッジ日時 2023-10-25 06:46:51
合計ジャッジ時間 1,648 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
16,232 KB
testcase_01 AC 78 ms
16,232 KB
testcase_02 AC 80 ms
16,232 KB
testcase_03 AC 85 ms
16,228 KB
testcase_04 WA -
testcase_05 AC 82 ms
16,232 KB
testcase_06 WA -
testcase_07 AC 85 ms
16,232 KB
testcase_08 AC 82 ms
16,232 KB
testcase_09 AC 84 ms
16,232 KB
testcase_10 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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
}
while res.any?{|a|a.any?{|c|c == ?-}}
  y = res.min_by{|a|[-a.count(?-), -a.count(?o)]}.index(?#)
  x = res[y].index(?-)
  res[y][x] = ?x
  res[x][y] = ?o
end
win = res[0].count(?o)
p 1 + res.map{|a|a.count(?o)}.sort_by{|o|-o}.uniq.index(win)
0