303963: CF762E. Radio stations
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Radio stations
题意翻译
一共有 n 个电台,对于每个电台 i 有三个参数: $x_i$, $r_i$, $f_i$,分别指它的一维坐标、作用半径和频率。如果两个电台的频率差值在 k 内,并且它们的作用范围都能覆盖到彼此,那么就称这两个电台相互干扰。问这 n 个站台中相互干扰的站台有多少对。题目描述
In the lattice points of the coordinate line there are $ n $ radio stations, the $ i $ -th of which is described by three integers: - $ x_{i} $ — the coordinate of the $ i $ -th station on the line, - $ r_{i} $ — the broadcasting range of the $ i $ -th station, - $ f_{i} $ — the broadcasting frequency of the $ i $ -th station. We will say that two radio stations with numbers $ i $ and $ j $ reach each other, if the broadcasting range of each of them is more or equal to the distance between them. In other words $ min(r_{i},r_{j})>=|x_{i}-x_{j}| $ . Let's call a pair of radio stations $ (i,j) $ bad if $ i<j $ , stations $ i $ and $ j $ reach each other and they are close in frequency, that is, $ |f_{i}-f_{j}|<=k $ . Find the number of bad pairs of radio stations.输入输出格式
输入格式
The first line contains two integers $ n $ and $ k $ ( $ 1<=n<=10^{5} $ , $ 0<=k<=10 $ ) — the number of radio stations and the maximum difference in the frequencies for the pair of stations that reach each other to be considered bad. In the next $ n $ lines follow the descriptions of radio stations. Each line contains three integers $ x_{i} $ , $ r_{i} $ and $ f_{i} $ ( $ 1<=x_{i},r_{i}<=10^{9} $ , $ 1<=f_{i}<=10^{4} $ ) — the coordinate of the $ i $ -th radio station, it's broadcasting range and it's broadcasting frequency. No two radio stations will share a coordinate.
输出格式
Output the number of bad pairs of radio stations.
输入输出样例
输入样例 #1
3 2
1 3 10
3 2 5
4 10 8
输出样例 #1
1
输入样例 #2
3 3
1 3 10
3 2 5
4 10 8
输出样例 #2
2
输入样例 #3
5 1
1 3 2
2 2 4
3 2 1
4 2 1
5 3 3
输出样例 #3
2
输入样例 #4
5 1
1 5 2
2 5 4
3 5 1
4 5 1
5 5 3
输出样例 #4
5