Solutions are presented as using the least memory and the fastest execution time. It also takes the top
10 most recent solutions from each language. If you want to limit to a specific index, click the
"Solved" button and go to that problem.
Problems
B"There are n robots driving along an OX axis. There are also two walls: one is at coordinate 0 and one is at coordinate m . The i -th robot starts at an integer coordinate x_i~(0 < x_i < m) and moves either left (towards the 0 ) or right with the speed of 1 unit per second. No two robots start at the same coordinate. Whenever a robot reaches a wall, it turns around instantly and continues his ride in the opposite direction with the same speed. Whenever several robots meet at the same integer coordinate, they collide and explode into dust. Once a robot has exploded, it doesn't collide with any other robot. Note that if several robots meet at a non-integer coordinate, nothing happens. For each robot find out if it ever explodes and print the time of explosion if it happens and -1 otherwise. The first line contains a single integer t ( 1 <= t <= 1000 ) -- the number of testcases. Then the descriptions of t testcases follow. The first line of each testcase contains two integers n and m ( 1 <= n <= 3 cdot 10^5 ; 2 <= m <= 10^8 ) -- the number of robots and the coordinate of the right wall. The second line of each testcase contains n integers x_1, x_2, ... , x_n ( 0 < x_i < m ) -- the starting coordinates of the robots. The third line of each testcase contains n space-separated characters 'L' or 'R' -- the starting directions of the robots ('L' stands for left and 'R' stands for right). All coordinates x_i in the testcase are distinct. The sum of n over all testcases doesn't exceed 3 cdot 10^5 . For each testcase print n integers -- for the i -th robot output the time it explodes at if it does and -1 otherwise. Here is the picture for the seconds 0, 1, 2 and 3 of the first testcase: Notice that robots 2 and 3 don't collide because they meet at the same point 2.5 , which is not in"... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
116408622 |
RealArtist |
C |
May 16, 2021, 1:48 p.m. |
OK |
GNU C11 |
TESTS |
10 |
1201 |
9318400 |
|
|
116437536 |
Werner_Yin |
C |
May 16, 2021, 10:23 p.m. |
OK |
GNU C++11 |
TESTS |
10 |
124 |
11366400 |
|
|
116387953 |
hnust_tanzhongsheng |
C |
May 16, 2021, 10:10 a.m. |
OK |
GNU C++11 |
TESTS |
10 |
171 |
5529600 |
|
|
116417374 |
wenzhuan |
C |
May 16, 2021, 3:33 p.m. |
OK |
GNU C++11 |
TESTS |
10 |
171 |
6144000 |
|
|
116408672 |
RealArtist |
C |
May 16, 2021, 1:49 p.m. |
OK |
GNU C++11 |
TESTS |
10 |
171 |
9113600 |
|
|
116441179 |
z_x |
C |
May 17, 2021, 1:32 a.m. |
OK |
GNU C++11 |
TESTS |
10 |
171 |
13414400 |
|
|
116423032 |
pikapikachu |
C |
May 16, 2021, 4:50 p.m. |
OK |
GNU C++11 |
TESTS |
10 |
171 |
16691200 |
|
|
116447525 |
BoringHacker |
C |
May 17, 2021, 4:38 a.m. |
OK |
GNU C++11 |
TESTS |
10 |
171 |
24985600 |
|
|
116411079 |
randop |
C |
May 16, 2021, 2:19 p.m. |
OK |
GNU C++11 |
TESTS |
10 |
187 |
10035200 |
|
|
116392414 |
Richard_ZRC |
C |
May 16, 2021, 10:51 a.m. |
OK |
GNU C++11 |
TESTS |
10 |
187 |
13721600 |
|
|
116394453 |
dagexiangdani |
C |
May 16, 2021, 11:11 a.m. |
OK |
GNU C++11 |
TESTS |
10 |
187 |
13824000 |
|
|
116399475 |
cup_of_tea_ |
C |
May 16, 2021, 12:03 p.m. |
OK |
GNU C++14 |
TESTS |
10 |
140 |
6348800 |
|
|
116397317 |
SF-Manman |
C |
May 16, 2021, 11:38 a.m. |
OK |
GNU C++14 |
TESTS |
10 |
155 |
11980800 |
|
|
116417279 |
Fascist_bigot |
C |
May 16, 2021, 3:32 p.m. |
OK |
GNU C++14 |
TESTS |
10 |
155 |
14438400 |
|
|
116406931 |
anhkha1004 |
C |
May 16, 2021, 1:28 p.m. |
OK |
GNU C++14 |
TESTS |
10 |
171 |
5632000 |
|
|
116387185 |
SuperJ6 |
C |
May 16, 2021, 10:06 a.m. |
OK |
GNU C++14 |
TESTS |
10 |
171 |
6246400 |
|
|
116434713 |
in_som_niac_25 |
C |
May 16, 2021, 8:33 p.m. |
OK |
GNU C++14 |
TESTS |
10 |
171 |
7475200 |
|
|
116427551 |
Potassium |
C |
May 16, 2021, 6:02 p.m. |
OK |
GNU C++14 |
TESTS |
10 |
171 |
8396800 |
|
|
116406362 |
Borna_Cizmarevic |
C |
May 16, 2021, 1:21 p.m. |
OK |
GNU C++14 |
TESTS |
10 |
171 |
14848000 |
|
|
116394506 |
ju_c_anik |
C |
May 16, 2021, 11:11 a.m. |
OK |
GNU C++14 |
TESTS |
10 |
171 |
214732800 |
|
|
116395382 |
Esquire |
C |
May 16, 2021, 11:19 a.m. |
OK |
GNU C++14 |
TESTS |
10 |
186 |
5427200 |
|
|
116420026 |
KIko643 |
C |
May 16, 2021, 4:07 p.m. |
OK |
GNU C++17 |
TESTS |
10 |
140 |
10649600 |
|
|
116384943 |
R35007 |
C |
May 16, 2021, 9:57 a.m. |
OK |
GNU C++17 |
TESTS |
10 |
140 |
10649600 |
|
|
116393239 |
mmello |
C |
May 16, 2021, 10:59 a.m. |
OK |
GNU C++17 |
TESTS |
10 |
155 |
5632000 |
|
|
116425045 |
sugmedic |
C |
May 16, 2021, 5:21 p.m. |
OK |
GNU C++17 |
TESTS |
10 |
155 |
7065600 |
|
|
116424891 |
xuzmeow |
C |
May 16, 2021, 5:19 p.m. |
OK |
GNU C++17 |
TESTS |
10 |
155 |
7372800 |
|
|
116410403 |
fajerso |
C |
May 16, 2021, 2:11 p.m. |
OK |
GNU C++17 |
TESTS |
10 |
155 |
7372800 |
|
|
116429156 |
grapo_Oranges |
C |
May 16, 2021, 6:30 p.m. |
OK |
GNU C++17 |
TESTS |
10 |
155 |
7987200 |
|
|
116440438 |
Blondie |
C |
May 17, 2021, 12:57 a.m. |
OK |
GNU C++17 |
TESTS |
10 |
155 |
8601600 |
|
|
116412418 |
strizh78 |
C |
May 16, 2021, 2:36 p.m. |
OK |
GNU C++17 |
TESTS |
10 |
155 |
9216000 |
|
|
116424640 |
Apron27 |
C |
May 16, 2021, 5:15 p.m. |
OK |
GNU C++17 |
TESTS |
10 |
155 |
10240000 |
|
|
116401414 |
Sakuyalove |
C |
May 16, 2021, 12:25 p.m. |
OK |
GNU C++17 (64) |
TESTS |
10 |
93 |
28979200 |
|
|
116389664 |
0xC0DEF |
C |
May 16, 2021, 10:23 a.m. |
OK |
GNU C++17 (64) |
TESTS |
10 |
108 |
52633600 |
|
|
116419175 |
pikel_rik |
C |
May 16, 2021, 3:55 p.m. |
OK |
GNU C++17 (64) |
TESTS |
10 |
109 |
6963200 |
|
|
116399216 |
silverfish |
C |
May 16, 2021, noon |
OK |
GNU C++17 (64) |
TESTS |
10 |
109 |
11673600 |
|
|
116413178 |
Chet8n |
C |
May 16, 2021, 2:44 p.m. |
OK |
GNU C++17 (64) |
TESTS |
10 |
124 |
5939200 |
|
|
116409145 |
Chet8n |
C |
May 16, 2021, 1:55 p.m. |
OK |
GNU C++17 (64) |
TESTS |
10 |
124 |
5939200 |
|
|
116394185 |
the_hyp0cr1t3 |
C |
May 16, 2021, 11:09 a.m. |
OK |
GNU C++17 (64) |
TESTS |
10 |
124 |
6144000 |
|
|
116426432 |
prottoyfuad |
C |
May 16, 2021, 5:44 p.m. |
OK |
GNU C++17 (64) |
TESTS |
10 |
124 |
6553600 |
|
|
116446690 |
lolok123 |
C |
May 17, 2021, 4:20 a.m. |
OK |
GNU C++17 (64) |
TESTS |
10 |
124 |
6656000 |
|
|
116410022 |
kira201 |
C |
May 16, 2021, 2:06 p.m. |
OK |
GNU C++17 (64) |
TESTS |
10 |
124 |
6860800 |
|
|
116400006 |
glebsamsonov |
C |
May 16, 2021, 12:09 p.m. |
OK |
Go |
TESTS |
10 |
374 |
14233600 |
|
|
116391606 |
0x3F |
C |
May 16, 2021, 10:41 a.m. |
OK |
Go |
TESTS |
10 |
374 |
14950400 |
|
|
116396103 |
hellstar7621 |
C |
May 16, 2021, 11:26 a.m. |
OK |
Java 11 |
TESTS |
10 |
404 |
10649600 |
|
|
116429105 |
Swapniltri |
C |
May 16, 2021, 6:29 p.m. |
OK |
Java 11 |
TESTS |
10 |
452 |
8192000 |
|
|
116414898 |
HBP |
C |
May 16, 2021, 3:04 p.m. |
OK |
Java 11 |
TESTS |
10 |
467 |
16281600 |
|
|
116398864 |
rohanxyzgg |
C |
May 16, 2021, 11:56 a.m. |
OK |
Java 11 |
TESTS |
10 |
468 |
24780800 |
|
|
116385273 |
bobib |
C |
May 16, 2021, 9:58 a.m. |
OK |
Java 11 |
TESTS |
10 |
482 |
15872000 |
|
|
116398887 |
dauom |
C |
May 16, 2021, 11:56 a.m. |
OK |
Java 11 |
TESTS |
10 |
498 |
37580800 |
|
|
116425388 |
Is2ac |
C |
May 16, 2021, 5:27 p.m. |
OK |
Java 11 |
TESTS |
10 |
717 |
38809600 |
|
|
116422177 |
ypa |
C |
May 16, 2021, 4:38 p.m. |
OK |
Java 11 |
TESTS |
10 |
872 |
6963200 |
|
|
116423773 |
amruthsai409 |
C |
May 16, 2021, 5:02 p.m. |
OK |
Java 11 |
TESTS |
10 |
1372 |
60108800 |
|
|
116427449 |
jamesfan961101 |
C |
May 16, 2021, 6:01 p.m. |
OK |
Java 11 |
TESTS |
10 |
1482 |
77107200 |
|
|
116413090 |
Frank0628 |
C |
May 16, 2021, 2:43 p.m. |
OK |
Java 8 |
TESTS |
10 |
436 |
36556800 |
|
|
116411055 |
YahiaSherif |
C |
May 16, 2021, 2:19 p.m. |
OK |
Java 8 |
TESTS |
10 |
452 |
20684800 |
|
|
116433783 |
liuy0523 |
C |
May 16, 2021, 8:07 p.m. |
OK |
Java 8 |
TESTS |
10 |
514 |
30617600 |
|
|
116441003 |
TheSawan |
C |
May 17, 2021, 1:24 a.m. |
OK |
Java 8 |
TESTS |
10 |
592 |
30208000 |
|
|
116402122 |
shaurya024 |
C |
May 16, 2021, 12:32 p.m. |
OK |
Java 8 |
TESTS |
10 |
1404 |
73011200 |
|
|
116419369 |
kkkkush |
C |
May 16, 2021, 3:58 p.m. |
OK |
Java 8 |
TESTS |
10 |
1621 |
15155200 |
|
|
116444274 |
dingzhao777 |
C |
May 17, 2021, 3:20 a.m. |
OK |
MS C++ 2017 |
TESTS |
10 |
249 |
9523200 |
|
|
116388724 |
JohnCode |
C |
May 16, 2021, 10:16 a.m. |
OK |
MS C++ 2017 |
TESTS |
10 |
764 |
33587200 |
|
|
116441390 |
sakapon |
C |
May 17, 2021, 1:41 a.m. |
OK |
.NET Core C# |
TESTS |
10 |
311 |
85606400 |
|
|
116441533 |
ayman1503 |
C |
May 17, 2021, 1:47 a.m. |
OK |
PHP |
TESTS |
10 |
1746 |
138240000 |
|
|
116436488 |
whaleee |
C |
May 16, 2021, 9:37 p.m. |
OK |
PyPy 2 |
TESTS |
10 |
1372 |
74342400 |
|
|
116386530 |
deepanshu_pali |
C |
May 16, 2021, 10:02 a.m. |
OK |
PyPy 3 |
TESTS |
10 |
670 |
37888000 |
|
|
116397893 |
not_tehlka |
C |
May 16, 2021, 11:45 a.m. |
OK |
PyPy 3 |
TESTS |
10 |
842 |
55091200 |
|
|
116432904 |
0e4ef622 |
C |
May 16, 2021, 7:44 p.m. |
OK |
PyPy 3 |
TESTS |
10 |
951 |
40038400 |
|
|
116427622 |
jimm89 |
C |
May 16, 2021, 6:03 p.m. |
OK |
PyPy 3 |
TESTS |
10 |
1138 |
41779200 |
|
|
116399376 |
abhishekk_7 |
C |
May 16, 2021, 12:02 p.m. |
OK |
PyPy 3 |
TESTS |
10 |
1169 |
64409600 |
|
|
116411662 |
mikasaloveseren |
C |
May 16, 2021, 2:26 p.m. |
OK |
PyPy 3 |
TESTS |
10 |
1216 |
48742400 |
|
|
116446654 |
dallasyan |
C |
May 17, 2021, 4:19 a.m. |
OK |
PyPy 3 |
TESTS |
10 |
1216 |
73830400 |
|
|
116403038 |
Melmetal |
C |
May 16, 2021, 12:43 p.m. |
OK |
PyPy 3 |
TESTS |
10 |
1341 |
78233600 |
|
|
116441839 |
phantomxxx |
C |
May 17, 2021, 1:59 a.m. |
OK |
PyPy 3 |
TESTS |
10 |
1465 |
65228800 |
|
|
116416011 |
YMSeah |
C |
May 16, 2021, 3:17 p.m. |
OK |
PyPy 3 |
TESTS |
10 |
1481 |
73625600 |
|
|
116418160 |
sh1194 |
C |
May 16, 2021, 3:43 p.m. |
OK |
Python 3 |
TESTS |
10 |
1122 |
40448000 |
|
|
116409722 |
aritrashome |
C |
May 16, 2021, 2:02 p.m. |
OK |
Python 3 |
TESTS |
10 |
1201 |
39936000 |
|
|
116441518 |
andrew.chang.sd |
C |
May 17, 2021, 1:46 a.m. |
OK |
Python 3 |
TESTS |
10 |
1216 |
37171200 |
|
|
116391640 |
satylogin |
C |
May 16, 2021, 10:42 a.m. |
OK |
Rust |
TESTS |
10 |
139 |
16384000 |
|
|
remove filters
Back to search problems