CF975D.Ghosts

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

The first line contains three integers nn , aa and bb ( 1n2000001 \leq n \leq 200000 , 1a1091 \leq |a| \leq 10^9 , 0b1090 \le |b| \le 10^9 ) — the number of ghosts in the universe and the parameters of the straight line.

Each of the next nn lines contains three integers xix_i , VxiV_{xi} , VyiV_{yi} ( 109xi109-10^9 \leq x_i \leq 10^9 , 109Vxi,Vyi109-10^9 \leq V_{x i}, V_{y i} \leq 10^9 ), where xix_i is the current xx -coordinate of the ii -th ghost (and yi=axi+by_i = a \cdot x_i + b ).

It is guaranteed that no two ghosts share the same initial position, in other words, it is guaranteed that for all (i,j)(i,j) xixjx_i \neq x_j for iji \ne j .

输入格式

Output one line: experience index of the ghost kind GXGX in the indefinite future.

输出格式

There are four collisions (1,2,T0.5)(1,2,T-0.5) , (1,3,T1)(1,3,T-1) , (2,4,T+1)(2,4,T+1) , (3,4,T+0.5)(3,4,T+0.5) , where (u,v,t)(u,v,t) means a collision happened between ghosts uu and vv at moment tt . At each collision, each ghost gained one experience point, this means that GX=42=8GX = 4 \cdot 2 = 8 .

In the second test, all points will collide when t=T+1t = T + 1 .

The red arrow represents the 1-st ghost velocity, orange represents the 2-nd ghost velocity, and blue represents the 3-rd ghost velocity.

输入输出样例

  • 输入#1

    4 1 1
    1 -1 -1
    2 1 1
    3 1 1
    4 -1 -1
    

    输出#1

    8
    
  • 输入#2

    3 1 0
    -1 1 0
    0 0 -1
    1 -1 -2
    

    输出#2

    6
    
  • 输入#3

    3 1 0
    0 0 0
    1 0 0
    2 0 0
    

    输出#3

    0
    

说明/提示

There are four collisions (1,2,T0.5)(1,2,T-0.5) , (1,3,T1)(1,3,T-1) , (2,4,T+1)(2,4,T+1) , (3,4,T+0.5)(3,4,T+0.5) , where (u,v,t)(u,v,t) means a collision happened between ghosts uu and vv at moment tt . At each collision, each ghost gained one experience point, this means that GX=42=8GX = 4 \cdot 2 = 8 .

In the second test, all points will collide when t=T+1t = T + 1 .

The red arrow represents the 1-st ghost velocity, orange represents the 2-nd ghost velocity, and blue represents the 3-rd ghost velocity.

首页