5364: Game on Plane

内存限制:128 MB 时间限制:1.000 S
评测方式:文本比较 命题人:
提交:2 解决:2

题目描述

Alice and Bob are playing a game. In this game, there are n straight lines on the 2D plane. Alice will select exactly k straight lines l1,l2,,lk among all the n straight lines first, then Bob will draw a straight line L. The penalty of Bob is defined as the number of lines in {l1,l2,,lk} that shares at least one common point with L. Note that two overlapping lines also share common points.

Alice wants to maximize the penalty of Bob while Bob wants to minimize it. You will be given these n lines, please write a program to predict the penalty of Bob for k=1,2,3,,n if both of the players play optimally.

输入

The first line contains a single integer T (1T500), the number of test cases. For each test case:

The first line contains a single integer n (1n100000), denoting the number of straight lines.

Each of the next n lines contains four integers xai,yai,xbi and ybi (0xai,yai,xbi,ybi109), denoting a straight line passes both (xai,yai) and (xbi,ybi). (xai,yai) will never be coincided with (xbi,ybi).

It is guaranteed that the sum of all n is at most 1000000.

输出

For each test case, output n lines, the i-th (1in) of which containing an integer, denoting the penalty of Bob when k=i.
 

样例输入 复制

2
2
1 1 2 2
0 0 2 3
3
1 1 2 2
1 1 2 2
3 2 5 4

样例输出 复制

0
1
0
0
0