1.题目介绍
2.题解
2.1 模拟
思路
模拟,使用二维数组记录每一块地皮实际被覆盖情况即可
代码
#include<bits/stdc++.h>
using namespace std;
int main(){
int n, m;
cin >> n >> m;
vector<vector<int>> point(n,vector<int>(n,0)) ;
for(int i = 0; i < m; i++){
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
for(int x = x1 - 1; x <= x2 - 1; x++){
for(int y = y1 - 1; y <= y2 -1; y++){
point[x][y]++;
}
}
}
int ans = 0;
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
cout << point[i][j] << ' ';
}
cout << endl;
}
}
标签:y2,int,x2,P3397,y1,x1,地毯
From: https://www.cnblogs.com/trmbh12/p/17980131