#include <bits/stdc++.h>
using namespace std;
int n, u, v, d, ans;
vector<int> a[100010];
struct node{
int x;
int s = 0;
}p;
void bfs() {
queue<node> q;
q.push({1, 0});
while (!q.empty()) {
p = q.front(), q.pop();
if (p.s >= d) continue;
for (int i = 0; i < a[p.x].size(); i ++) {
q.push({a[p.x][i], p.s + 1}), ans ++;
}
}
}
int main() {
scanf("%d%d", &n, &d);
for (int i = 1; i <= n; i ++) {
scanf("%d%d", &u, &v);
if (u > v) swap(u, v);
a[u].push_back(v);
}
bfs();
printf("%d", ans);
return 0;
}
为什么bf函数第二行和第七行会报错