48 lines
1.2 KiB
C++
48 lines
1.2 KiB
C++
#include <iostream>
|
|
#include <vector>
|
|
using namespace std;
|
|
|
|
int main(){
|
|
// 重要公式 a[i][j] = a[i][j-1] + a[i-1][j] - a[i-1][j-1] + d[i][j]
|
|
ios::sync_with_stdio(0);
|
|
cin.tie(0);
|
|
int n, m;
|
|
cin >> n >> m;
|
|
vector<vector<int>> d(n+2, vector<int>(n+2, 0));
|
|
for(int i = 0; i < m; ++i){
|
|
int x1, x2, y1, y2;
|
|
cin >> x1 >> y1 >> x2 >> y2;
|
|
d[x1][y1] += 1;
|
|
d[x1][y2+1] -= 1;
|
|
d[x2+1][y1] -=1;
|
|
d[x2+1][y2+1] += 1;
|
|
}
|
|
vector<vector<int>> a(n+2, vector<int>(n+2, 0));
|
|
|
|
/*
|
|
a[0][0] = d[0][0];
|
|
for(int i = 0; i <= n; ++i){
|
|
for(int j = 0; j <= n; ++j){
|
|
if (i != 0 && j != 0) a[i][j] = a[i][j-1] + a[i-1][j] - a[i-1][j-1] + d[i][j];
|
|
else if (i == 0 && j != 0) a[i][j] = a[i][j-1] + d[i][j];
|
|
else if (i != 0 && j == 0) a[i][j] = a[i-1][j] + d[i][j];
|
|
}
|
|
}
|
|
*/
|
|
|
|
for (int i = 1; i <= n; ++i) {
|
|
for (int j = 1; j <= n; ++j) {
|
|
a[i][j] = a[i][j - 1] + a[i - 1][j] - a[i - 1][j - 1] + d[i][j];
|
|
}
|
|
}
|
|
|
|
for(int i = 1; i <= n; ++i){
|
|
for(int j = 1; j <= n; ++j){
|
|
cout << a[i][j] << " ";
|
|
}
|
|
cout << endl;
|
|
}
|
|
cout << endl;
|
|
return 0;
|
|
}
|