logo AlgoBeat OnlineJudge
登录 注册

#213730. [NWRRC 2022] K-Shaped Figures

内存限制:512 MiB 时间限制:3000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

Let's say that three segments on a plane form a if:

  • two of them share a common endpoint;
  • this common endpoint lies strictly inside the third segment;
  • these two segments are located on the same side with respect to the third one;
  • all three segments are pairwise not collinear.

You are given a collection of segments on the plane. Find the number of triples of segments from this collection that form a K-shaped figure.

输入格式

Each test contains multiple test cases. The first line contains the number of test cases (). The description of the test cases follows.

The first line of each test case contains a single integer --- the number of segments ().

The -th of the following lines contains four integers , , , --- the coordinates of endpoints of the -th segment (). All segments have positive lengths. Some segments may coincide.

It is guaranteed that the sum of over all test cases does not exceed .

输出格式

For each test case, print a single integer --- the number of triples of segments that form a K-shaped figure.

样例

样例输入 1

2
5
0 0 0 10
0 5 3 10
0 5 3 0
0 5 7 4
0 5 6 2
8
0 0 10 10
3 4 4 4
4 4 4 5
3 4 4 4
7 7 7 8
7 7 8 7
5 5 4 6
5 5 3 7

样例输出 1

6
2