Ask AI
Open a hint-first prompt in a new AI chat. Grok may ask you to confirm before sending.
Open Claude Desktoptrees · path-queries · counting
The organizer’s problem statement is available at the official source link.
tree pair comparison
Compare the maximum edge on two unique paths
For each unordered pair p < q, compare the maximum edge weight on its unique path in tree X with the corresponding maximum in tree Y. Count pairs satisfying costX(p,q) <= costY(p,q).
| Tree X path | Tree Y path | Pair test |
|---|---|---|
| max edge X(p,q) | max edge Y(p,q) | compare as stated |
- 1
Choose node pair
Choose one unordered node pair. - 2
Compare path maxima
Find the maximum edge weight on its unique path in each weighted tree. - 3
Count matching pairs
Count the pair when its two path maxima satisfy the official comparison relation.
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.