Problem list
Log in
#coci00301 · COCI 2013/2014 Contest 5

Trokuti

Gold I 1.0 s 32 MB

Authors: Adrian Satja Kurdija, Marin Tomić 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. Important note: No three lines will intersect at the same point.

Input

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^{th}$ line. All numbers will be lesser than $10^{9}$.

Output

The first and only line of output must consist of the required number from the task. A possible position of lines. $5^{th}$ round, February $15^{th}$, 2014 Authors: Adrian Satja Kurdija, Marin Tomić

Constraints

In test cases worth 40% of total points, N will be lesser than 1000.

Example 1

Input
6
0 1 0
-5 3 0
-5 -2 25
0 1 -3
0 1 -2
-4 -5 29
Output
10

Example 2

Input
5
-5 3 0
-5 -3 -30
0 1 0
3 7 35
1 -2 -1
Output
10

Clarification of the first example: The example corresponds to the image in the task.

Source
COCI 2013/2014 Contest 5
Appears in
Not part of a ladder, contest or set yet.
Accepted 0 Submissions 0 Acceptance 0% Solvers 0

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code