#P14049. [SDCPC 2019] Tokens on the Segments
[SDCPC 2019] Tokens on the Segments
题目描述
Consider segments on a two-dimensional plane, where the endpoints of the -th segment are and . One can put as many tokens as he likes on the integer points of the plane (recall that an integer point is a point whose and coordinates are both integers), but the coordinates of the tokens must be different from each other.
What's the maximum possible number of segments that have at least one token on each of them?
输入格式
The first line of the input contains an integer (about ), indicating the number of test cases. For each test case:
The first line contains one integer (), indicating the number of segments.
For the next lines, the -th line contains 2 integers (), indicating the coordinates of the two endpoints of the -th segment.
It's guaranteed that at most test cases have .
输出格式
For each test case output one line containing one integer, indicating the maximum possible number of segments that have at least one token on each of them.
2
3
1 2
1 1
2 3
3
1 2
1 1
2 2
3
2
提示
For the first sample test case, one can put three tokens separately on and .
For the second sample test case, one can put two tokens separately on and .