#41464: python


suyueh (suyueh)

學校 : 不指定學校
編號 : 272111
來源 : [101.12.162.212]
最後登入時間 :
2024-11-10 22:20:41
a694. 吞食天地二 | From: [125.229.229.84] | 發表日期 : 2024-07-29 13:59

from sys  import stdin
from itertools import accumulate
for s in stdin:
    n,m=map(int,s.split())
    arr=[[0]*(n+1)]
    for _ in range(n):
        t=[int(x) for x in stdin.readline().split()]
        t=list(accumulate([0]+t))
        v=arr[-1]
        v=[aa+aaa for aa ,aaa in zip(t,v)]
        arr.append(v)
        #print(arr)
    for _ in range(m):
        y1,x1,y2,x2=map(int,stdin.readline().split())
        r=arr[y2][x2]-arr[y2][x1-1]-arr[y1-1][x2]+arr[y1-1][x1-1]
        print(r)
 
ZeroJudge Forum