From 804c18f85b14274d16c03e501cc6193c61560fe1 Mon Sep 17 00:00:00 2001 From: hanyixuanten <105723997+hanyixuanten@users.noreply.github.com> Date: Sun, 19 Jul 2026 17:07:32 +0800 Subject: [PATCH] new file: P11964.cpp --- P11964.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 P11964.cpp diff --git a/P11964.cpp b/P11964.cpp new file mode 100644 index 0000000..03a5bf0 --- /dev/null +++ b/P11964.cpp @@ -0,0 +1,41 @@ +#include +#include +#include +using namespace std; +bool vis[510][25]; +int n, m, k; +vector g[510]; +void dfs(int now, int dep) +{ + if (vis[now][dep]) + return; + vis[now][dep] = 1; + if (dep == k) + return; + for (int i = 0; i < g[now].size(); i++) + dfs(g[now][i], dep + 1); +} +int main() +{ + scanf("%d%d%d", &n, &m, &k); + for (int j = 0; j < m; j++) + { + int u, v; + scanf("%d%d", &u, &v); + g[u].push_back(v), g[v].push_back(u); + } + for (int i = 1; i <= n; i++) + { + memset(vis, 0, sizeof vis); + dfs(i, 0); + for (int dep = 1; dep <= k; dep++) + { + int ans = 0; + for (int now = 1; now <= n; now++) + ans += vis[now][dep]; + printf("%d ", ans); + } + printf("\n"); + } + return 0; +}