我有一个很妙的思路

P1162 填涂颜色

CSPJ10pts @ 2022-01-30 18:21:13

遍历,如果遇到1了,它的右下角一定是0, 而且在闭合圈内。再用连通块就好了。不信可以试试。


by newbie_QwQ @ 2022-01-30 18:28:35

hack:

6
0 0 0 0 0 0 
0 1 1 1 1 1 
0 0 0 1 0 1
0 0 0 1 0 1
0 0 0 0 1 1
0 0 0 0 0 0 

by wssbi @ 2022-01-30 18:29:52

hack:

5
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1

by coldy_rainy @ 2022-01-30 18:36:33

@Kenneth123

......


by CSPJ10pts @ 2022-01-30 18:47:15

但这个思路能过


by __KrNalty__ @ 2022-01-30 19:04:57

@wssbi 圈内至少有一个 0


by wssbi @ 2022-01-30 19:08:38

@KrNalty 名字生效(

4
1 1 1 1
1 1 1 1
1 0 1 1
1 1 1 1

by 5k_sync_closer @ 2022-02-01 14:28:26

@Kenneth123 出题人不会闲的没事写各种乱搞再自己卡掉

可以找管理加强下数据


by tsjtsj @ 2022-02-02 21:25:13

#include<cstdio>
int n,a[35][35],x,y;
int fx[4]={0,1,0,-1},fy[4]={1,0,-1,0};
bool z;
void go(int u,int v)
{
    a[u][v]=2;
    for(int i=0;i<4;i++)
    {
        int xx=u+fx[i],yy=v+fy[i];
        if(!a[xx][yy])go(xx,yy);
    }
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
    {
        scanf("%d",&a[i][j]);
        if(!z&&a[i][j])x=i+1,y=j+1,z=1;
    }
    go(x,y);
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        printf("%d ",a[i][j]);
        puts("");
    }
}

by XieCY9336 @ 2022-03-06 11:14:37

……

9
0 0 0 0 0 0 0 0 0
0 1 1 1 0 1 1 1 0
0 1 0 1 0 1 0 1 0
0 1 0 1 1 1 0 1 0
0 1 0 0 0 0 0 1 0
0 1 0 0 0 0 0 1 0
0 1 1 1 1 1 1 1 0
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0

by CSPJ10pts @ 2022-03-25 13:22:19

@XieCY1216 这个是可以的啊


| 下一页