我尽力了……
by 火星─002 @ 2021-01-19 14:31:51
这是什么玄学做法...
建议学搜索
by zhy137036 @ 2021-01-19 15:01:35
我学会搜索了,但#3还是不过……
```
#include<iostream>//X
using namespace std;
int n,a[31][31];
void paint(int x,int y)
{
for(int i=0;i<=n;i++)
for(int j=0;j<=n;j++)
if(a[i][j]==x)a[i][j]=y;
}
int main()
{
cin>>n;
for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)cin>>a[i][j];
a[0][0]=2;
for(int i=0;i<=n+1;i++)
for(int j=0;j<=n+1;j++)
if(a[i][j]==2)
{
if(a[i-1][j]==0)a[i-1][j]=2;
if(a[i+1][j]==0)a[i+1][j]=2;
if(a[i][j-1]==0)a[i][j-1]=2;
if(a[i][j+1]==0)a[i][j+1]=2;
}
for(int i=n+1;i>=0;i--)
for(int j=n+1;j>=0;j--)
if(a[i][j]==2)
{
if(a[i-1][j]==0)a[i-1][j]=2;
if(a[i+1][j]==0)a[i+1][j]=2;
if(a[i][j-1]==0)a[i][j-1]=2;
if(a[i][j+1]==0)a[i][j+1]=2;
}
paint(0,3);
paint(2,0);
paint(3,2);
for(int i=1;i<=n;i++,cout<<'\n')for(int j=1;j<=n;j++)cout<<a[i][j]<<' ';
return 0;
}
```
by 火星─002 @ 2021-03-21 12:37:30
我过了!!!
31改成32就好了
(今天是个值得纪念的日子,我AC了一道做了一年1个月零13天的题目)
by 火星─002 @ 2021-03-21 12:53:58
[https://www.luogu.com.cn/record/list?pid=P1162&user=313727&page=1](https://www.luogu.com.cn/record/list?pid=P1162&user=313727&page=1)
by 火星─002 @ 2021-03-21 12:55:25