#include <iostream>
using namespace std;
int map[1025][1025];
long long sum[1025][1025];
void sumMaker(int N)
{
for (int i = 0; i <= N; i++)
{
sum[i][0] = 0;
sum[0][i] = 0;
}
for (int i = 1; i <= N; i++)
{
for (int j = 1; j <= N; j++)
{
sum[i][j] = sum[i][j - 1] + sum[i - 1][j] - sum[i - 1][j - 1] + map[i][j];
}
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
int N, M;
cin >> N >> M;
int x1, x2, y1, y2;
for (int i = 1; i <= N; i++)
{
for (int j = 1; j <= N; j++)
{
cin >> map[i][j];
}
}
sumMaker(N);
for (int i = 0; i < M; i++)
{
cin >> x1 >> y1 >> x2 >> y2;
cout << sum[x2][y2] - sum[x2][y1 - 1] - sum[x1 - 1][y2] + sum[x1 - 1][y1 - 1] << "\n";
}
}
๋งํ cin!!!!!!!
'๐ก๐ธ๐ธ๐ถ๐ฃ: ๐๐๐๐๐๐พ๐๐ฝ๐ > ์๊ณ ๋ฆฌ์ฆ ๋ฌธ์ ํ์ด' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
BOJ17404 : RGB๊ฑฐ๋ฆฌ2 (Gold 4) (0) | 2021.08.17 |
---|---|
BOJ1149 : RGB๊ฑฐ๋ฆฌ (Silver 1) (0) | 2021.08.17 |
BOJ2012 : ๋ฑ์๋งค๊ธฐ๊ธฐ (Silver 3) (0) | 2021.08.13 |
BOJ1343 : ํด๋ฆฌ์ค๋ฏธ๋ ธ (Silver 5) (0) | 2021.08.13 |
BOJ11170 : 0์ ๊ฐ์ (Silver 5) (0) | 2021.08.11 |