結果

問題 No.755 Zero-Sum Rectangle
ユーザー むらためむらため
提出日時 2019-01-25 20:41:49
言語 Nim
(2.0.2)
結果
AC  
実行時間 1,709 ms / 2,000 ms
コード長 892 bytes
コンパイル時間 2,426 ms
コンパイル使用メモリ 66,512 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-14 02:52:38
合計ジャッジ時間 19,548 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

import sequtils
template times*(n:int,body) = (for _ in 0..<n: body)

proc getchar_unlocked():char {. importc:"getchar_unlocked",header: "<stdio.h>" .}
proc scan(): int =
  var minus = false
  while true:
    let k = getchar_unlocked()
    if k == '-' : minus = true
    elif k < '0' or k > '9': break
    else: result = 10 * result + k.ord - '0'.ord
  if minus: result *= -1

let n = scan()
let m = scan()
var A = newSeqWith(m+1,newSeqWith(m+1,0))
for y in 1..m:
  for x in 1..m:
    A[x][y] = scan()
for x in 1..m:
  for y in 1..m:
    A[x][y] = A[x-1][y] + A[x][y-1] - A[x-1][y-1] + A[x][y]

proc calcSum(ax,ay,bx,by:int):int = A[bx][by] - A[bx][ay] - A[ax][by] + A[ax][ay]

n.times:
  let y = scan()
  let x = scan()
  var ans = 0
  for ax in 0..<x:
    for ay in 0..<y:
      for bx in x..m:
        for by in y..m:
          if calcSum(ax,ay,bx,by) == 0:
            ans += 1
  echo ans
0