Skip to content

Commit a0360ce

Browse files
author
hangyeol
committed
122차 2번 문제풀이 (참고..)
1 parent 6a50195 commit a0360ce

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import sys
2+
3+
def main():
4+
input = sys.stdin.readline
5+
6+
N, M = map(int, input().split())
7+
A = [list(map(int, input().split())) for _ in range(N)]
8+
9+
S = [[0] * (M+1) for _ in range(N+1)]
10+
11+
for i in range(1, N+1):
12+
for j in range(1, M+1):
13+
S[i][j] = A[i-1][j-1] + S[i-1][j] + S[i][j-1] - S[i-1][j-1]
14+
15+
K = int(input())
16+
17+
for _ in range(K):
18+
x1, y1, x2, y2 = map(int, input().split())
19+
result = (S[x2][y2] - S[x1-1][y2] - S[x2][y1-1] + S[x1-1][y1-1])
20+
21+
print(result)
22+
23+
if __name__ == '__main__':
24+
main()

0 commit comments

Comments
 (0)