این مسابقه به صورت حضوری در تاریخ ۱۴ آذر ۱۴۰۳ در سایت دانشکده برق و کامپیوتر دانشگاه تهران برگزار می‌شود. علاقه‌مندان می‌توانند به صورت همزمان در مسابقه آنلاین که شامل همان سوالات می‌باشد شرکت کنند.

Chameleons


  • محدودیت زمان: ۱ ثانیه
  • محدودیت حافظه: ۶۴ مگابایت

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 LL meters in length there are NN 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 KK 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)modK(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 NN, KK and LL from the task.

he ithi^{th} of the following NN lines contains the integer did_i that denotes the distance between the ithi^{th} chameleon and the left end of the stick, then the integer bib_i that denotes the color of the ithi^{th} chameleon and the character ‘L’ (Left) or 'R' (Right) that denote the direction of movement of the ithi^{th} chameleon. All integers did_i will be unique and given in strictly ascending order.

Output🔗

The output must contain KK lines, the ithi^{th} line containing the total trip taken by the chameleons in color ii.

Constraints🔗

  • 1N1051 \leq N \leq 10^5
  • 1K401 \leq K \leq 40
  • 1L1061 \leq L \leq 10^6
  • 0diL0 \leq d_i \leq L
  • 0biK10 \leq b_i \leq K-1

input 1🔗

4 3 7
1 0 R
3 0 R
4 1 L
6 2 R
Plain text

output 1🔗

10.0
4.0
1.0
Plain text

input 2🔗

5 4 4
1 1 R
3 3 L
4 2 R
5 0 L
Plain text

output 2🔗

2.5
4.0
2.5
4.0
Plain text
ارسال پاسخ برای این سؤال
در حال حاضر شما دسترسی ندارید.