結果
| 問題 |
No.440 2次元チワワ問題
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-10-29 18:55:50 |
| 言語 | Ruby (3.4.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,033 bytes |
| コンパイル時間 | 44 ms |
| コンパイル使用メモリ | 7,680 KB |
| 実行使用メモリ | 27,648 KB |
| 最終ジャッジ日時 | 2024-11-24 18:22:08 |
| 合計ジャッジ時間 | 93,720 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 12 TLE * 14 |
コンパイルメッセージ
Main.rb:3: warning: assigned but unused variable - w Syntax OK
ソースコード
def main
lines = STDIN.readlines
h, w = lines[0].split.map {|x| x.to_i}
s = []
h.times {|i| s << lines[i + 1].chomp}
q = lines[h + 1].chomp.to_i
q_array = []
q.times {|i| q_array << lines[h + i + 2].split.map {|x| x.to_i - 1}.to_a}
q_array.each do |a, b, c, d|
result = 0
a.upto(c) do |y|
c_count = 0
b.upto(d) do |x|
if s[y][x] == "c"
c_count += 1
end
end
w_count = d - b + 1 - c_count
result += w_count * (w_count - 1) / 2 * c_count
end
b.upto(d) do |x|
c_count = 0
a.upto(c) do |y|
if s[y][x] == "c"
c_count += 1
end
end
w_count = c - a + 1 - c_count
result += w_count * (w_count - 1) / 2 * c_count
end
puts result
end
end
main()