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 Aix+Biy+Ci=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 1000000007.

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 (1N300000), the number of lines.

Each of the following N lines contains three integers: Ai, Bi and Ci, the numbers defining the ith line.

All numbers will have absolute value at most 109.

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 1000.

Sample Input 1

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

Sample Output 1

Copy
10

Explanation for Sample Output 1

The example corresponds to the image in the task.

Sample Input 2

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

Sample Output 2

Copy
10

Comments

There are no comments at the moment.