|
|
Vectors calculations uses square roots. Could this lead to not very precise floats and wrong results? Edited by author 05.10.2023 13:50 Edited by author 05.10.2023 13:50 In this sort of problems rounding errors could be the source of problems. That's why you shall avoid using float types here. The problem is completely solvable in integers. Check that you indeed turn after reaching point B, i.e. that intersection point is not between A and B or you don't even reach B. There is something else. My code checks turning before B but still got WA on #5. Spaceship can go only forward, so check - there shouldn't be any backward movement. Test #5 is about that. Edited by author 05.10.2023 14:33 a-b and c-d are close, but not touching each other. -2 0 0 -1 0 0 0 1 0 0 1000000 1 Spend 10 submissions to realise, that I don't return anything from function, that must return bool value 0 0 0 1 0 0 2 1 1 2 2 1 ans Invalid Совет для тех кто решает векторами, лично у меня не получилось сдать задачу векторами, пришлось писать уравнения прямой в пространстве Check (AB,CD)==0 (orthogonality). Check (AB, CD, DA) ==0 (planarity). Check AD>AC>AB, AC>BC, BD>BC (order). Check whether the projections to XY, YZ, XZ craddle each other continuations. It is sufficient to check only the projections to XY plane to get Accepted verdict. Sounds too complex. If we replace C, D with their orthogonal projection on AB, then all steps except first collapse to only one step (check D = C*a, a > 1). Still too complex, though. Over 20 lines in Python. There should be more simple solution... Edited by author 26.12.2017 04:30 No lengths or projections XY, etc. Using scalar product (sp) and triple product (tp) it is at most five conditions: sp(ab,cd) == 0 and tp(ab,bc,cd) == 0 and # ⟂ and planar sp(ab,bc) >= 0 and # C after B sp(cd,bc) >= 0 and # BC goes in direction of CD sp(cd,bd) >= sp(cd,bc) # D after C Can someone tell me what the test#13 example please? Something like AB and CD are orthogonal and complanar and there is no right such point E, that E lies on AB-line, E lies on CD line and the angle AED is ninety degrees. |
|
|