#P15935. [TOPC 2021] Garden Park
[TOPC 2021] Garden Park
题目描述
In the Garden park, there are places of interest (numbered from 1 to ) and trails (numbered from 1 to ) connecting the places of interest. For every , trail has two ends at place and place , and the trail does not pass any place of interest except its ends. Moreover, the trails do not have any intersection except the ends.
To protect the garden, visitors may only walk along the trails (in any direction) and inside the places of interest. For any pair of places of interest where , there exists a sequence of trails satisfying the following conditions.
- Place is an end of trail .
- Place is an end of trail .
- For , trail and trail have a common end.
- If place is the common end of trails and for some , then cannot be a common end of any other pairs of trails in .
In other words, a visitor move from to by walking along the trails without visiting a place of interest twice. Such a sequence is called a simple path from to .
The administration division of the park plans to host an event in the park. It puts labels on the trails. For trail , the label on is an integer , and a visitor can learn by walking through trail . A simple path from to is with strictly increasing labels if . By reporting distinct simple paths with strictly increasing labels to the administration division, a visitor may win free tickets for future visits.
Your friend George just visited the park, and learned all labels on the trails. He wants to win free tickets for future visits with you. Please write a program to compute the number of distinct simple paths with strictly increasing labels in the garden park.
输入格式
The first line contains one integer . The -th line contains three integers . Trail connects place and , and the label on trail is .
输出格式
Output the number of distinct simple paths with strictly increasing labels in the garden park.
3
1 2 3
2 3 7
5
5
1 2 2
2 3 2
1 4 5
5 4 5
9
提示
- for .
- for .
- for .
- for .