#P10378. Determining the Range of School B's Enrollment

    ID: 12384 Type: Default 1000ms 256MiB

Determining the Range of School B's Enrollment

Determining the Range of School B's Enrollment

There are a total of (n) students, each uniquely numbered from 1 to (n), coming from two schools: School (A) and School (B). They participate in (m) communication sessions. In the (i)-th session, two students with indices (u_i) and (v_i) discuss topics of common interest and become friends. Note that in every session, the two students come from different schools (i.e. all communications are only between students of different schools).

As an advisor of School (A), you are curious about the scale of School (B). Assuming that the given friendship relations (edges) must always occur between students from different schools, determine the minimum and maximum possible number of students that could be in School (B) under any valid assignment of students to the two schools.

Explanation:
Each communication implies that the two involved students must belong to opposite schools. Hence, if you view the students as vertices and each communication as an edge, the graph is guaranteed to be bipartite. For each connected component in this graph, there are exactly two ways to assign the students to School (A) and School (B) (i.e. the bipartite coloring can be flipped). For a component with bipartition sizes (x) and (y) (with (x+y) being the number of students in that component), you can either assign (x) students to School (B) or (y) students to School (B). To minimize the total for School (B), choose the smaller count in each component; to maximize, choose the larger count. Isolated students (with no communications) can be arbitrarily assigned to either school.

inputFormat

The first line contains two integers (n) and (m) ((1 \leq n \leq 10^5), (0 \leq m \leq 10^5)), representing the number of students and the number of communications respectively.

Each of the next (m) lines contains two integers (u_i) and (v_i) ((1 \leq u_i, v_i \leq n), (u_i \neq v_i)) indicating that student (u_i) and student (v_i) have communicated. It is guaranteed that each communication is between students from different schools.

outputFormat

Output two integers separated by a space: the minimum and maximum possible number of students in School (B), respectively.

sample

1 0
0 1

</p>