結果

問題 No.755 Zero-Sum Rectangle
ユーザー ikdikd
提出日時 2018-12-08 20:28:34
言語 Nim
(2.0.2)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 786 bytes
コンパイル時間 3,067 ms
コンパイル使用メモリ 68,332 KB
実行使用メモリ 7,704 KB
最終ジャッジ日時 2023-09-13 21:22:03
合計ジャッジ時間 32,302 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,704 KB
testcase_01 TLE -
testcase_02 TLE -
testcase_03 TLE -
testcase_04 TLE -
testcase_05 TLE -
testcase_06 TLE -
testcase_07 TLE -
testcase_08 TLE -
testcase_09 TLE -
testcase_10 TLE -
testcase_11 AC 2 ms
4,380 KB
evil_1 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import strutils, sequtils

proc main() =
  let
    nm = stdin.readLine.split.map(parseInt)
    (n, m) = (nm[0], nm[1])
    a = (0..<m).mapIt(stdin.readLine.split.map(parseInt))
  var acc = newSeqWith(m+1, newSeq[int64](m+1))
  for i in 0..<m:
    acc[i+1][1] = a[i][0]
    for j in 1..<m:
      acc[i+1][j+1] = acc[i+1][j]+a[i][j]
  for j in 0..<m:
    for i in 1..<m:
      acc[i+1][j+1]+=acc[i][j+1]
  for _ in 0..<n:
    let
      yx = stdin.readLine.split.map(parseInt)
      (y, x) = (yx[0], yx[1])
    var tot = 0
    for sy in 1..m:
      for sx in 1..m:
        for gy in sy..m:
          for gx in sx..m:
            if sy<=y and y<=gy and sx<=x and x<=gx:
              if acc[gy][gx]-acc[gy][sx-1]-acc[sy-1][gx]+acc[sy-1][sx-1]==0:
                tot+=1
    echo tot
main()
0