- محدودیت زمان: ۱ ثانیه
- محدودیت حافظه: ۲۵۶ مگابایت
Everyday Space Runners go to the Enghelab Sports Complex for a morning run in the “Health Road”. They love to exercise and workout. The only thing bothering them is that some people are not punctual and they do not arrive on-time. After days of discussion, they decided to run individually.
They run along on the axis Ox. For every person there are three parameters characterizing their behavior: $t_i, s_i, f_i$ — the moment of time when the $i$-th person starts running, the start point and the end point of the run respectively. Each person moves in a straight line along the road from $s_i$ to $f_i$ with a constant speed of either $1$ or $-1$ depending on the direction.
If two or more persons meet at the health road (they are at the same point at the same time, no matter which directions they are going) they all greet each other. Like in the normal life, every pair of people greet each other at most once.
You task is to calculate for every person how many people she greets while running along the health road. Please, pay attention to the fact that $i$-th person may meet and greet any other person at points $s_i$ and $f_i$.
After a person achieves the destination point $f_i$ she moves out of the road and cannot greet anyone else. The same rule applies to the start of the run: a person cannot greet anyone until she appears on the road.
ورودی
At the first line of the input, integer $N$ is given – number of groups. In the each of next $N$ lines, there are three space-separated integers $t_i, s_i, f_i$.
$$1 \leq N \leq 50$$ $$1 \leq t_i, s_i, f_i \leq 10^9$$$$s_i \neq t_i$$
خروجی
The single line of the output should contain a sequence of $n$ integers $r_1, r_2, \dots, r_n$ separated by a space, where $r_i$ denotes the number of times which the $i$-th person greets other people while running along the health road.
مثالها
ورودی نمونه ۱
4
1 1 2
1 3 2
2 2 3
2 1 2
خروجی نمونه ۱
2 2 2 0
ورودی نمونه ۲
4
10 1 1000000000
10 1000000000 1
5 1 3
8 5 3
خروجی نمونه ۲
1 1 0 0
ارسال پاسخ برای این سؤال