Preparando MOJI

BCPC

4000ms 262144K

Description:

BCPC stands for Byteforces Collegiate Programming Contest, and is the most famous competition in Byteforces.

BCPC is a team competition. Each team is composed by a coach and three contestants. Blenda is the coach of the Bit State University(BSU), and she is very strict selecting the members of her team.

In BSU there are n students numbered from 1 to n. Since all BSU students are infinitely smart, the only important parameters for Blenda are their reading and writing speed. After a careful measuring, Blenda have found that the i-th student have a reading speed equal to ri (words per minute), and a writing speed of wi (symbols per minute). Since BSU students are very smart, the measured speeds are sometimes very big and Blenda have decided to subtract some constant value c from all the values of reading speed and some value d from all the values of writing speed. Therefore she considers ri' = ri - c and wi' = wi - d.

The student i is said to overwhelm the student j if and only if riwj' > rjwi'. Blenda doesn’t like fights in teams, so she thinks that a team consisting of three distinct students i, j and k is good if i overwhelms j, j overwhelms k, and k overwhelms i. Yes, the relation of overwhelming is not transitive as it often happens in real life.

Since Blenda is busy preparing a training camp in Codeforces, you are given a task to calculate the number of different good teams in BSU. Two teams are considered to be different if there is at least one student that is present in one team but is not present in the other. In other words, two teams are different if the sets of students that form these teams are different.

Input:

In the first line of the input three integers n, c and d (3 ≤ n ≤ 345678, 1 ≤ c, d ≤ 109) are written. They denote the number of students Blenda can use to form teams, the value subtracted from all reading speeds and the value subtracted from all writing speeds respectively.

Each of the next n lines contains two integers ri and wi (0 < ri, wi ≤ 109, |ri - c| + |wi - d| > 0). There are no two students, such that both their reading and writing speeds coincide, i.e. for every i ≠ j condition |ri - rj| + |wi - wj| > 0 holds.

Output:

Print the number of different teams in BSU, that are good according to Blenda's definition.

Sample Input:

5 2 2
1 1
4 1
2 3
3 2
3 4

Sample Output:

4

Sample Input:

7 6 6
3 2
1 7
5 7
3 7
6 4
8 9
8 5

Sample Output:

11

Note:

In the first sample the following teams are good: (i = 1, j = 2, k = 3), (i = 2, j = 5, k = 1), (i = 1, j = 4, k = 3), (i = 5, j = 1, k = 4).

Note, that for example the team (i = 3, j = 1, k = 2) is also good, but is considered to be the same as the team (i = 1, j = 2, k = 3).

Informação

Codeforces

Provedor Codeforces

Código CF592E

Tags

binary searchgeometrytwo pointers

Submetido 0

BOUA! 0

Taxa de BOUA's 0%

Datas 09/05/2023 09:01:24

Relacionados

Nada ainda