#P14478. 手心

    ID: 13436 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>贪心二分洛谷原创O2优化构造洛谷月赛

手心

Description

Little E has nn AIs. They no longer want to solve the maximum independent set problem, so they often gather to play Genshin Impact.

Little E noticed that recently fewer AIs are playing Genshin Impact. After investigation, it was found that there are mm pairs of AIs in conflict. Specifically, for a conflicting pair (u,v)(u,v), uu and vv will not play Genshin Impact simultaneously.

It is guaranteed that no duplicate conflicts are counted, and no AI conflicts with itself. Conflicts are unordered.

Little E does not know exactly which AIs are in conflict. But Little E wants to know, in the best and worst cases, what is the maximum number of AIs that can play Genshin Impact simultaneously.

Formal Description

Find the maximum and minimum possible sizes of the maximum independent set over all undirected simple graphs with nn vertices and mm edges.

Input Format

This problem has multiple test cases.

For each test point, the first line contains a positive integer TT, indicating the number of test cases.

Then, TT lines follow, each containing two integers n,mn, m for one test case.

Output Format

For each test case, output one line. Output two answers separated by a space, indicating the maximum number of AIs playing Genshin Impact simultaneously in the best and worst cases.

2
8 4
4 4
7 4
2 2

Hint

Sample Explanation

For the first test case:

  • For the first question, we can construct the graph with edges (1,2),(1,3),(1,4),(1,5)(1,2),(1,3),(1,4),(1,5). Then AIs 22 to 88 can play, so the answer is 77.
  • For the second question, we can construct the graph with edges (1,2),(3,4),(5,6),(7,8)(1,2),(3,4),(5,6),(7,8). Then AIs 1,3,5,71,3,5,7 can play, so the answer is 44.

For the second test case:

  • For the first question, we can construct the graph with edges (1,2),(1,3),(1,4),(2,3)(1,2),(1,3),(1,4),(2,3). Then AIs 3,43,4 can play, so the answer is 22.
  • The second question has the same construction, so the answer is 22.

Data Range

There are 55 test points in this problem, each with equal score.

Data ID nn\le TT\le Special Constraints
11 55 1010 None
22 10710^7
33 10910^9 10510^5 mn(n1)23m\ge \dfrac{n(n-1)}{2}-3
44 mnm\le n
55 None

For all data, 1T1051\le T\le 10^5, 1n1091\le n\le 10^9, 0mn(n1)20\le m\le \dfrac{n(n-1)}{2}.