結果
問題 |
No.755 Zero-Sum Rectangle
|
ユーザー |
|
提出日時 | 2018-12-04 01:24:36 |
言語 | Crystal (1.14.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 389 bytes |
コンパイル時間 | 14,669 ms |
コンパイル使用メモリ | 295,800 KB |
実行使用メモリ | 9,756 KB |
最終ジャッジ日時 | 2024-06-30 19:37:11 |
合計ジャッジ時間 | 20,953 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 RE * 2 TLE * 1 |
ソースコード
n,m=gets.not_nil!.split.map &.to_i a=[[0]*-~m] a+=m.times.map{[0]+gets.not_nil!.split.map(&.to_i).to_a}.to_a (m+1).times{|y|m.times{|x|a[y][x+1]+=a[y][x]}} (m+1).times{|x|m.times{|y|a[y+1][x]+=a[y][x]}} n.times{ r=0 x,y=gets.not_nil!.split.map(&.to_i) (0...x).each{|x0|(x..m).each{|x1| (0...y).each{|y0|(y..m).each{|y1| r+=1 if a[x0][y0]-a[x1][y0]-a[x0][y1]+a[x1][y1]==0 }}}} p r }