为了让蓝桥杯不变成蓝桥悲,我决定在舒适的周日再来一道题。
例:
输入:
6
0 0 0 0 0 0
0 0 1 1 1 1
0 1 1 0 0 1
1 1 0 0 0 1
1 0 0 0 0 1
1 1 1 1 1 1
输出:
0 0 0 0 0 0
0 0 1 1 1 1
0 1 1 2 2 1
1 1 2 2 2 1
1 2 2 2 2 1
1 1 1 1 1 1
答案思路
#include<iostream>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;
//跑一遍洪水灌溉
const int N=35;
typedef pair<int,int> PII;
int n;
int g[N][N];
bool st[N][N];
queue<PII> q;
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
void bfs(int x1,int y1)
{
q.pus