65 lines
1.6 KiB
C++
65 lines
1.6 KiB
C++
//weiwancheng
|
|
#include <iostream>
|
|
#include<cstdio>
|
|
using namespace std;
|
|
int main()
|
|
{
|
|
int xy,r;
|
|
//bool a[251][251]={0};
|
|
int ans[252][252]={0};
|
|
cin>>xy>>r;
|
|
for(int i=1;i<=xy;i++){
|
|
for(int j=1;j<=xy;j++){
|
|
bool u;
|
|
cin>>u;
|
|
if(u==1){
|
|
printf("(%d,%d):",i,j);
|
|
int qx=i-r,qy=j-r;
|
|
int hx=i+r+1,hy=j+r+1;
|
|
if(qx<1){
|
|
qx=1;
|
|
}
|
|
if(qy<1){
|
|
qy=1;
|
|
}
|
|
if(hx>xy){
|
|
hx=xy+1;
|
|
}
|
|
if(hy>xy){
|
|
hy=xy+1;
|
|
}
|
|
printf("%d %d %d %d ",qx,qy,hx,hy);
|
|
ans[qx][qy]++;
|
|
ans[i][hy]--;
|
|
ans[j][hx]--;
|
|
ans[hx][hy]--;
|
|
printf("%d %d %d %d\n",ans[qx][qy],ans[i][hy],ans[j][hx],ans[hx][hy]);
|
|
}
|
|
}
|
|
}
|
|
|
|
for(int i=1;i<=xy;i++){
|
|
for(int j=1;j<=xy;j++){
|
|
// ans[i][j]+=ans[i-1][j]+ans[i][j-1]-ans[i-1][j-1];
|
|
cout<<ans[i][j];
|
|
if(j!=xy){
|
|
cout<<" ";
|
|
}else{
|
|
cout<<endl;
|
|
}
|
|
}
|
|
}
|
|
|
|
for(int i=1;i<=xy;i++){
|
|
for(int j=1;j<=xy;j++){
|
|
ans[i][j]+=ans[i-1][j]+ans[i][j-1]-ans[i-1][j-1];
|
|
cout<<ans[i][j];
|
|
if(j!=xy){
|
|
cout<<" ";
|
|
}else{
|
|
cout<<endl;
|
|
}
|
|
}
|
|
}
|
|
}
|