题面
题解
求图中点到点的最短距离,因为所有点的距离都是1,我们就可以用bfs来做,每次逐层搜索,从1到n一定是距离最短的,用宽搜的模板即可
代码
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
const int N = 1e5 + 10;
int n, m;
int h[N], e[N
求图中点到点的最短距离,因为所有点的距离都是1,我们就可以用bfs来做,每次逐层搜索,从1到n一定是距离最短的,用宽搜的模板即可
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
const int N = 1e5 + 10;
int n, m;
int h[N], e[N