← CSES Better
Open official problem ↗Count Ordered Path Decompositions of a Tree
ZIO · 2025 · Zonal Informatics Olympiad · P4
Ask AI
Open a hint-first prompt in a new AI chat. Grok may ask you to confirm before sending.
Open Claude Desktoptrees · paths · combinatorics · dynamic-programming
The organizer’s problem statement is available at the official source link.
tree paths
Every road belongs to exactly one chosen path
Each array element is a simple path between two cities; together, the paths partition the tree edges. Schematic structure only; vertices and edges represent the task relation, not an official sample. Schematic graph only; labels and edges show the task relation, not an official sample.
- 1
Choose endpoints
Each pair (A,B) names the unique simple path between two tree vertices. - 2
Cover each edge once
The selected paths must be edge-disjoint and cover every road exactly once. - 3
Canonicalize order
Sort the endpoint pairs lexicographically to form the required array; count distinct resulting arrays modulo 997.
Tools
1
2
3
4
5
6
7
8
9
10
11
12
Draft saved locally
|12 lines, 156 charsRun output
Run your code to see output.