F. Monkeying AroundWhen
题目描述
the monkey professor leaves his class for a short time, all the monkeys go bananas. N monkeys are lined up sitting side by side on their chairs. They each have the same joke book. Before the professor returns, M jokes were heard.
Each of the M jokes are said in the order given and have the following properties:
xi - position of the monkey who said it.
li – index of the joke in the book.
ki – volume the monkey says that joke.
When the monkey at position xi says the joke li, all monkeys at a distance less than or equal to ki from that monkey (including the monkey who said the joke) will fall off their chairs in laughter if they have never heard the joke li before.
If the joke li has been heard anytime during the past before, and the monkey hears it again, then he will sit back up in his chair.
A monkey can fall off his chair more than once (every time he hears a new joke), and if he is already on the ground and hears a new joke, he will stay on the ground.
Can you figure out how many monkeys will be in their seats by the time the professor comes back?
输入
The first line of input is T – the number of test cases.
The first line of each test case is N, M (1 ≤ N ≤ 105) (1 ≤ M ≤ 105) – the number of monkeys in the class, and the number of jokes said before the professor returns.
The next M lines contain the description of each joke: xi, li, ki (1 ≤ xi ≤ N) (1 ≤ li ≤ 105) (0 ≤ ki ≤ N).
输出
For each test case, output on a line a single integer - the number of monkeys in their seats after all jokes have been said.
样例
inputCopy
1
10 7
3 11 0
3 11 2
5 12 1
8 13 2
7 11 2
10 12 1
9 12 0
outputCopy
3
题意
挺难想的一道题,,, 一年前不会现在还是不会emmm
在一个班级里,教授离开后,猴子们开始讲笑话。每只猴子讲笑话时,周围一定范围内的猴子如果之前没听过这个笑话就会笑倒。反之,如果之前听过则会坐回椅子上。问题是:当教授回来时,有多少只猴子还坐在椅子上?
833

被折叠的 条评论
为什么被折叠?



