COCI '13 Contest 5 #5 Trokuti

View as PDF

Submit solution


Points: 15 (partial)
Time limit: 1.0s
Memory limit: 32M

Problem type

You are given N lines, their equations being A_i x + B_i y + C_i = 0 in the coordinate plane. Calculate the number of triangles whose sides lie on the given lines. Since the result can be very large, output the number modulo 1\,000\,000\,007.

A possible position of lines.

Important note: No three lines will intersect at the same point.

Input Specification

The first line of input contains the integer N (1 \le N \le 300\,000), the number of lines.

Each of the following N lines contains three integers: A_i, B_i and C_i, the numbers defining the i^\text{th} line.

All numbers will have absolute value at most 10^9.

Output Specification

The first and only line of output must consist of the required number from the task.

Scoring

In test cases worth 40\% of total points, N will be at most 1\,000.

Sample Input 1

6
0 1 0
-5 3 0
-5 -2 25
0 1 -3
0 1 -2
-4 -5 29

Sample Output 1

10

Explanation for Sample Output 1

The example corresponds to the image in the task.

Sample Input 2

5
-5 3 0
-5 -3 -30
0 1 0
3 7 35
1 -2 -1

Sample Output 2

10

Comments

There are no comments at the moment.