| Show all threads Hide all threads Show all messages Hide all messages | | Instruction how to solve. | Mahilewets | 2099. Space Invader | 14 Apr 2026 01:02 | 6 | 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 And you probably made a mistake. Your 3rd step would make a mistake if intercection is incide AB, incide CD. I am now stuck with 19test and I used some real bulletproof solution, without using float at all. ---------- I do 3rd step buy solving 3x3 matrix and finding t and z, just instead of dividing i only check +or- for i in range(3): if mtrx[i][1]!=0: if ( mtrx[i][0]>=0 and mtrx[i][1]>0 )or( mtrx[i][0]<=0 and mtrx[i][1]<0 ): t=True else: t=False for i in range(3): if mtrx[i][2]!=0: if ( mtrx[i][0]>=0 and mtrx[i][2]>0 )or( mtrx[i][0]<=0 and mtrx[i][2]<0 ): z=True else: z=False return t and z ------------ I start to believe, that it is incorrect test result not my soultion Edited by author 13.04.2026 01:15 Edited by author 13.04.2026 01:15 Edited by author 13.04.2026 01:15 Edited by author 13.04.2026 01:18 Edited by author 13.04.2026 01:50 counterexample 4 0 0 -1 0 0 0 4 0 0 -6 0 It is invalid, but your your order is OK #Finally did it. Now i see why indie games are so bugged def Vect3d(start,end): #int to int return (end[0]-start[0],end[1]-start[1],end[2]-start[2]) def multSc(vecta,vectb):#int to int rslt=0 for i in (0,1,2): rslt+=vecta[i]*vectb[i] return rslt def multVct(va,vb): #int to int x=va[1]*vb[2]-va[2]*vb[1] y=va[2]*vb[0]-va[0]*vb[2] z=va[0]*vb[1]-va[1]*vb[0] return (x,y,z) #vc=t*va+z*vb def TZbool(va,vb,vc): #always int and bool, no division mtrx=[[0,0,0],[0,0,0],[0,0,0]] for i in (0,1,2): mtrx[i][0]=va[i] mtrx[i][1]=vb[i] mtrx[i][2]=vc[i] c1=0 r1=0 while c1<2: if mtrx[r1][c1]!=0: for r2 in (0,1,2): if r2!=r1: for c2 in (0,1,2): if c2!=c1: mtrx[r2][c2]=mtrx[r2][c2]*mtrx[r1][c1]-mtrx[r1][c2]*mtrx[r2][c1] mtrx[r2][c1]=0 c1+=1 r1=(r1+1)%3 ######################### t=False #t>=0 for i in (0,1,2): #only one mtrx[i][0]!=0 in solved 3x2 mtrx if (mtrx[i][0]>0 and mtrx[i][2]>=0) or (mtrx[i][0]<0 and mtrx[i][2]<=0): t=True z=False #z>=0 for i in (0,1,2): if (mtrx[i][1]>0 and mtrx[i][2]>=0) or (mtrx[i][1]<0 and mtrx[i][2]<=0): z=True return t and z A=tuple(map(int,input().split())) B=tuple(map(int,input().split())) C=tuple(map(int,input().split())) D=tuple(map(int,input().split())) goNext=True if goNext: #check if turning 90 AB=Vect3d(A,B) DC=Vect3d(D,C) if multSc(AB,DC)!=0: goNext=False print('Invalid') if goNext: #check if AB and CD intersect AD=Vect3d(A,D) if multSc(AD,multVct(AB,DC))!=0: goNext=False print('Invalid') if goNext: BC=Vect3d(B,C) CD=Vect3d(C,D) # -DC if TZbool(AB,CD,BC): print('Valid') else: print('Invalid') Edited by author 14.04.2026 01:12 | | WA #8 | 👨🏻💻 Spatarel Dan Constantin | 2099. Space Invader | 10 Apr 2026 14:18 | 1 | WA #8 👨🏻💻 Spatarel Dan Constantin 10 Apr 2026 14:18 Input: -4 2 2 4 2 2 0 3 -1 0 1 -2 Output: Invalid | | Is it possible to get wrong answer because of rounding numbers? | roman velichkin | 2099. Space Invader | 6 Oct 2023 17:43 | 2 | 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. | | WA5 | die_young | 2099. Space Invader | 5 Oct 2023 14:21 | 3 | WA5 die_young 30 Jul 2018 23:38 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. Re: WA5 roman velichkin 5 Oct 2023 13:45 There is something else. My code checks turning before B but still got WA on #5. Re: WA5 roman velichkin 5 Oct 2023 14:21 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 | | WA9 | Ade | 2099. Space Invader | 25 May 2023 20:35 | 1 | WA9 Ade 25 May 2023 20:35 a-b and c-d are close, but not touching each other. -2 0 0 -1 0 0 0 1 0 0 1000000 1 | | WA1 | andreyDagger | 2099. Space Invader | 15 Feb 2022 16:09 | 1 | WA1 andreyDagger 15 Feb 2022 16:09 Spend 10 submissions to realise, that I don't return anything from function, that must return bool value | | test | Toshpulatov (MSU Tashkent) | 2099. Space Invader | 22 Dec 2020 17:59 | 1 | test Toshpulatov (MSU Tashkent) 22 Dec 2020 17:59 0 0 0 1 0 0 2 1 1 2 2 1 ans Invalid Совет для тех кто решает векторами, лично у меня не получилось сдать задачу векторами, пришлось писать уравнения прямой в пространстве | | Wa #13 | liudy | 2099. Space Invader | 3 Jun 2017 17:53 | 2 | Wa #13 liudy 13 Aug 2016 08:45 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. |
|
|