Time limit
1s
Memory limit
128 MB
There are an odd number of marbles that all have the same shape but different weights. The marbles are numbered from 1 to N, and the goal is to find the marble that is exactly in the middle by weight.
A balance scale can compare two marbles and tell which one is heavier. You are given the results of M such comparisons. Using these results and every relationship that is forced by them, count how many marbles can never be the median-weight marble.
A marble cannot be the median if at least (N+1)/2 marbles are known to be heavier than it, or if at least (N+1)/2 marbles are known to be lighter than it.
The first line contains the number of marbles N and the number of compared pairs M. N is odd, 1 <= N <= 99, and 1 <= M <= N(N-1)/2.
Each of the next M lines contains two marble numbers a and b. This means marble a is heavier than marble b.
Print one integer: the number of marbles that can never have the middle weight.