for __ in range(readInt()): n,s,w = readInts() v = readInts() d = readInts() p = readInts() c = readInts() t =[] carl,sumi = 0,0 for i in range(n): if d[i]==0 and p[i]>0: carl = p[i]*1.0+c[i]*1.0 if i>=1: carl -= v[i]*1.0*sum(t)*1.0 if carl<0: carl = 0 if (((carl*1.0-c[i])/v[i]*1.0)>(w*1.0/s*1.0)) and ((((carl*1.0-c[i])/v[i]*1.0)-(w*1.0/s*1.0))*1.0*v[i]>0.000001): t.append(w*1.0/s*1.0) else: t.append(carl*1.0/v[i]*1.0) t.append(w*1.0/s*1.0) elif d[i]==0 and p[i]<=0: carl = p[i]*1.0+c[i]*1.0 if carl<0: carl = 0 if i>=1: carl -= v[i]*1.0*sum(t)*1.0 if carl<0: carl = 0 if (((carl*1.0-c[i])/v[i]*1.0)>(w*1.0/s*1.0)) and ((((carl*1.0-c[i])/v[i]*1.0)-(w*1.0/s*1.0))*1.0*v[i]>0.000001): t.append(w*1.0/s*1.0) else: t.append(carl*1.0/v[i]*1.0) t.append(w*1.0/s*1.0) elif d[i]==1 and p[i]<0: carl = abs(p[i]*1.0)+c[i]*1.0 if i>=1: carl -= v[i]*1.0*sum(t)*1.0 if carl<0: carl = 0 if (((carl*1.0-c[i])/v[i]*1.0)>(w*1.0/s*1.0)) and ((((carl*1.0-c[i])/v[i]*1.0)-(w*1.0/s*1.0))*1.0*v[i]>0.000001): t.append(w*1.0/s*1.0) else: t.append(carl*1.0/v[i]*1.0) t.append(w*1.0/s*1.0) elif d[i]==1 and p[i]>=0: carl = p[i]*-1.0+c[i]*1.0 if carl<0: carl = 0 if i>=1: carl -= v[i]*1.0*sum(t)*1.0 if carl<0: carl = 0 if (((carl*1.0-c[i])/v[i]*1.0)>(w*1.0/s*1.0)) and ((((carl*1.0-c[i])/v[i]*1.0)-(w*1.0/s*1.0))*1.0*v[i]>0.000001): t.append(w*1.0/s*1.0) else: t.append(carl*1.0/v[i]*1.0) t.append(w*1.0/s*1.0) printdec(sum(t))
Hi, I was unable to solve this problem in the contest. I liked the tester’s approach which is similar to my approach. I think the editorialist explanation for tester’s code is confusing. It should be "he checks the location of car’s rear when chef has reached the lane and he checks for the location of front of the car after chef moves instantly. The editorialist said that he checks for the location of rear both the time. If I understood it wrong please let me know.
Thank you so much @aryanc403. I really dont know how did that happen
Now that I think of it…seeing {10}^{6} instead of {10}^{-6} must have been hilarious for you given how much this question revolves around this number xD
Yes. I do handle (the car has already crossed x = 0 and the car is crossing x = 0 and the car reaches x = 0 when chef crosses). Even a counter test case would be helpful. Thanks
I dont know why people are writing such a big code for this problem, while it can be done in few lines
Its natural to feel like this. Take my stand here-
I dont know why people are writing so many if-else conditions when only 3 suffice and prove to be exhaustive. (Check editorialist solution for implementation).
Whatever strikes the guy/~girl to solve the problem.
Did you have a look at tester’s code? That explanation is there to understand his code primarily. Hence, certain omissions were done assuming you’d refer to it. What you said about car’s back and front, is dealt here- If, we observe that the car was at different side. Basically, this section was meant to serve as “reference/comments” to tester’s code.
Tester calculates the location of cars rear at both times. He derives the location of car’s front using that. Nonetheless, thanks for bringing it to my notice, I will edit it to be clearer