#P10378. [GESP202403 七级] 交流问题

[GESP202403 七级] 交流问题

Background

Related multiple-choice and true/false questions: https://ti.luogu.com.cn/problemset/1147.

Problem Description

nn students from two schools AA and BB gather together to communicate with each other. For convenience, we number these students from 11 to nn. They have conducted mm communications. In the ii-th communication, the students numbered uiu_i and viv_i discussed topics they were interested in and became new friends.

Since the purpose of this event is to promote friendship between the two schools, only students from different schools communicate with each other. Students from the same school do not communicate with each other.

As an advisor of school AA, you are very interested in the size of school BB. You want to find the minimum possible number of students in school BB, and the maximum possible number of students in school BB.

Input Format

The first line contains two positive integers, representing the number of students nn and the number of communications mm.
The next mm lines each contain two integers ui,viu_i, v_i, representing one communication.

Output Format

Output one line with two integers separated by a single space, representing the minimum possible number of students in school BB and the maximum possible number of students in school BB.

4 3
1 2
2 3
4 2

1 3
7 5
1 2
2 3
4 2
5 6
6 7

2 5

Hint

Constraints

  • For 30%30\% of the testdata, n17n \leq 17, m50m \leq 50.
  • For 60%60\% of the testdata, n500n \leq 500, m2000m \leq 2000.
  • For all testdata, 1ui,vin1051 \leq u_i, v_i \leq n \leq 10^5, 1m2×1051 \leq m \leq 2\times 10^5. The input is valid, meaning that every communication is guaranteed to be between students from different schools.

Translated by ChatGPT 5