cuirongchen @ 2024-12-07 17:16:28
#include<bits/stdc++.h>
using namespace std;
const int N=1100;
int n,m,b[N][N];
string s;
int main(){
cin>>n>>m;
for(int i=1;i<=m;i++){
int w,x,y,z;
cin>>w>>x>>y>>z;
b[w][x]+=1;
b[y+1][x]-=1;
b[w][z+1]-=1;
b[y+1][z+1]+=1;
}
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
b[i][j]=b[i][j]+b[i-1][j]+b[j-1][i]-b[i-1][j-1];
cout<<b[i][j]<<" ";
}
cout<<"\n";
}
return 0;
}
by Naxidadog @ 2024-12-08 09:16:47
@cuirongchen
你的
b[i][j]=b[i][j]+b[i-1][j]+b[j-1][i]-b[i-1][j-1];
改为
b[i][j]=b[i][j]+b[i-1][j]+b[i][j-1]-b[i-1][j-1];
就能过了。