[Solution] Unique Occurrences Codeforces Solution | Codeforces Problem Solution 2022
F. Unique Occurrences
time limit per test
6 secondsmemory limit per test
1024 megabytesinput
standard inputoutput
standard outputYou are given a tree, consisting of vertices. Each edge has an integer value written on it.
Let be the number of values that appear exactly once on the edges of a simple path between vertices and .
Solution Click Below:- CLICK HERE
Calculate the sum of over all pairs of vertices and such that .
Input
The first line contains a single integer () — the number of vertices in the tree.
Each of the next lines contains three integers and () — the description of an edge: the vertices it connects and the value written on it.
The given edges form a tree.
Output
Print a single integer — the sum of over all pairs of vertices and such that .
No comments:
Post a Comment