Walk on Tree
You are given a tree with $N$ nodes (numbered $1$ through $N$). The tree is rooted at node $r$. For each node, find the number of walks with length $K$ from the root to this node modulo $998244353$. A *walk* from node $a$ to node $b$ with length $K$ is defined as a sequence of nodes $(u_1, u_2, \dots, u_{K+1})$, where $u_1 = a, u_{K+1} = b$ and for each valid $i$, there is an edge between nodes $
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start