|
|||
future friends
In a group the relation between the members can be either friendly or neutral or hostile. (the relations are symmetric!) It is possible, that between some members the currently neutral relation will become friendly. According to some scientists, if A and B are in neutral relation, but one can get from A to B through a sequence of friendly relations, then the relation of A and B will become friendly in the future, for we will refer to A and B as a future friends.
If in a group of four people,
the pairs 1 and 4 -> are in neutral relation, but they are connected by a 1 -> 2 -> 4 friendly path 2 and 3 -> are in neutral relation, but they are connected by a 2 -> 1 -> 3 friendly path 3 and 4 are also connected by a 2 -> 1 -> 3 friendly path, but they are in a hostile relationOne can conclude, that in this group each member has exactly 1 future friend, therefore
the group's average number of future friends is 1=(1+1+1+1)/4 .
Task: Given the relations in a group compute the average number of future friends. Input Specification
The three space separated numbers Output SpecificationM
A single line with the average number of future friends for the group described in the input.
Round your result to Sample Input 1
Sample Output 1
Sample Input 2
Sample Output 2
Sample Input 3
Sample Output 3
|
|||
University of Debrecen; Faculty of Informatics; v. 09/30/2024 |