#P8398. [CCC 2022 S4] Good Triplets

[CCC 2022 S4] Good Triplets

Problem Description

Andrew\rm Andrew is a very curious student. One day, he drew a circle on paper with its center at (0,0)(0,0). Let the circumference be CC. The coordinates of each point on the circle are:

Now Andrew\rm Andrew marks nn points on the circle. The ii-th point is placed at pip_i. Andrew\rm Andrew may place multiple points at the same position.

A good triangle (a,b,c)(a,b,c) is defined as:

  • 1a<b<cn1 \le a < b < c \le n.
  • The origin (0,0)(0,0) lies strictly inside the triangle whose vertices are at pap_a, pbp_b, and pcp_c. Note in particular that the origin is not on the boundary of the triangle.

Andrew\rm Andrew asks you how many good triangles there are.

Input Format

The first line contains two integers n,cn, c, representing the number of points and the circumference of the circle.

The next line contains nn integers. Their meaning is described above.

Output Format

Output an integer xx, indicating that there are xx good triangles.

8 10
0 2 5 5 6 9 0 0
6

Hint

Explanation for Sample 11:

Andrew\rm Andrew drew the following figure:

The origin lies strictly inside the triangle with vertices at p1p_1, p2p_2, and p5p_5, so (1,2,5)(1,2,5) is a good triangle. The other five good triplets are (2,3,6)(2,3,6), (2,4,6)(2,4,6), (2,5,6)(2,5,6), (2,5,7)(2,5,7), and (2,5,8)(2,5,8).

For 20%20\% of the testdata: 3n2003 \le n \le 200, 3c1063 \le c \le 10^6.

For another 20%20\% of the testdata: 3n1063 \le n \le 10^6, 3c60003 \le c \le 6000.

For 40%40\% of the testdata: 3n1063 \le n \le 10^6, 3c1063 \le c \le 10^6, and all point positions are pairwise distinct.

For 100%100\% of the testdata: 3n1063 \le n \le 10^6, 3c1063 \le c \le 10^6.

Translated by ChatGPT 5