whatever point a robot arrives at a divider, it pivots right away and proceeds with his ride the other way with a similar speed. At whatever point a few robots meet at a similar integer organize, they impact and detonate into dust. When a robot has detonated, it doesn't slam into some other robot. Note that if a few robots meet at a non
Correct answer will be upvoted else downvoted. Computer science.
At whatever point a robot arrives at a divider, it pivots right away and proceeds with his ride the other way with a similar speed.
At whatever point a few robots meet at a similar integer organize, they impact and detonate into dust. When a robot has detonated, it doesn't slam into some other robot. Note that if a few robots meet at a non-integer facilitate, nothing occurs.
For every robot see whether it at any point detonates and print the hour of blast on the off chance that it occurs and −1 in any case.
Input
The primary line contains a solitary integer t (1≤t≤1000) — the number of testcases.
Then, at that point, the depictions of t testcases follow.
The primary line of each testcase contains two integers n and m (1≤n≤3⋅105; 2≤m≤108) — the number of robots and the organize of the right divider.
The second line of each testcase contains n integers x1,x2,… ,xn (0<xi<m) — the beginning directions of the robots.
The third line of each testcase contains n space-isolated characters 'L' or 'R' — the beginning headings of the robots ('L' represents left and 'R' represents right).
All directions xi in the testcase are unmistakable.
The amount of n over all testcases doesn't surpass 3⋅105.
Output
For each testcase print n integers — for the I-th robot output the time it detonates at on the off chance that it does and −1 in any case.
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Operations Research : Applications and Algorithms](https://www.bartleby.com/isbn_cover_images/9780534380588/9780534380588_smallCoverImage.gif)
![C++ for Engineers and Scientists](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)
![Operations Research : Applications and Algorithms](https://www.bartleby.com/isbn_cover_images/9780534380588/9780534380588_smallCoverImage.gif)
![C++ for Engineers and Scientists](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)