+ محدودیت زمان: ۱ ثانیه
+ محدودیت حافظه: ۶۴ مگابایت
----------
On the football pitch of the University of Tehran, there is, if we are to believe the Guinness Book of Records, the longest stick in the world. On that stick of $L$ meters in length there are $N$ cheerful chameleons. Each chameleon is moving along the stick with constant speed of 1 m/s in one of two possible directions (left or right) and is colored in one of the possible $K$ colors.
It is known that the chameleons of the University of Tehran worship the ancient ant laws that dictate that the walk along the stick must be continued until the end of the stick is reached (which means getting off it), and when a collision with another chameleon takes place, you must turn 180 degrees and continue the walk in the opposite direction. Additionally, after a chameleon colored in a moving to the left collides with a chameleon colored in b moving to the right, the chameleon moving to the left before the collision takes the color of the chameleon moving to the right before the collision (so, color b), while the chameleon moving to the right before the collision takes a new color $(a + b) \hspace{2pt} mod \hspace{2pt} K$.
If you are given the initial positions, colors and directions of movement of all the chameleons, for each color determine the total trip taken by the chameleons in that color before getting off the stick.
# Input
The first line of input contains the integers $N$, $K$ and $L$ from the task.
he $i^{th}$ of the following $N$ lines contains the integer $d_i$ that denotes the distance between the $i^{th}$ chameleon and the left end of the stick, then the integer $b_i$ that denotes the color of the $i^{th}$ chameleon and the character ‘L’ (Left) or 'R' (Right) that denote the direction of movement of the $i^{th}$ chameleon. All integers $d_i$ will be unique and given in strictly ascending order.
# Output
The output must contain $K$ lines, the $i^{th}$ line containing the total trip taken by the chameleons in color $i$.
# Constraints
* $1 \leq N \leq 10^5 $
* $1 \leq K \leq 40 $
* $1 \leq L \leq 10^6 $
* $0 \leq d_i \leq L $
* $0 \leq b_i \leq K-1 $
## input 1
```
4 3 7
1 0 R
3 0 R
4 1 L
6 2 R
```
## output 1
```
10.0
4.0
1.0
```
## input 2
```
5 4 4
1 1 R
3 3 L
4 2 R
5 0 L
```
## output 2
```
2.5
4.0
2.5
4.0
```
ارسال پاسخ برای این سؤال
در حال حاضر شما دسترسی ندارید.