QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#421875#6763. Triangle PendantshaletomeRE 4ms11016kbPython34.1kb2024-05-26 08:53:222024-05-26 08:53:22

Judging History

你现在查看的是最新测评结果

  • [2024-05-26 08:53:22]
  • 评测
  • 测评结果:RE
  • 用时:4ms
  • 内存:11016kb
  • [2024-05-26 08:53:22]
  • 提交

answer

# right behind ya

from cmath import *
import cmath

from math import *

def angle(z,y,a):
    ttt=(z**2+y**2-a**2)/2/y/z
    # if ttt>1:
    #     return 0
    # if ttt<-1:
    #     return pi
    # if abs(ttt)>1:
    #     print("WHAT")
    #     exit()
    return acos(ttt)

    lo=0
    hi=pi
    while hi-lo>0.0000001:
        mid=(hi+lo)/2
        dst=(z-y*cos(mid))**2+(y*sin(mid))**2
        if dst > a*a:
            hi=mid
        else:
            lo=mid
    return (hi+lo)/2

def getcos(x,XX,lenzya):
    return cos(angle(x,XX,lenzya))
    # XM=XX*2/3
    # return (x*x+(3/2*XM)**2-lenzya**2)/3/x/XM

def getmid(z,y,a):

    mid=angle(z,y,a)
    lenzya = (z+y*cos(mid))**2+(y*sin(mid))**2
    lenzya /= 4
    # if lenzya<0:
    #     print("WHAT")
    #     exit()
    return sqrt(lenzya)

def istri(a,b,c):
    return a+b>c and a+c>b and b+c>a

def geths(y,z,a):
    A=angle(y,z,a)
    y1=y
    y2=0
    z1=z*cos(A)
    z2=z*sin(A)
    h1=(y1+z1)/2
    h2=(y2+z2)/2
    th=atan2(h2,h1)
    ya=y*cos(th)
    yb=-y*sin(th)
    za=z*cos(A-th)
    zb=z*sin(A-th)
    return ya,yb,za,zb

def chsl1(x,y,z,a,b,c):
    if not istri(y,z,a):
        return None
    D=0+0j
    B=y+0j
    C=z*cmath.exp(1j*angle(y,z,a))
    CB=B-C
    CA=b*cmath.exp(1j*angle(b,a,c))*CB/cmath.polar(CB)[0]
    A=CA+C
    if x < cmath.polar(A)[0]-0.000001:
        return None
    M=(A+B+C)/3
    A=A*cmath.polar(M)[0]/M
    B=B*cmath.polar(M)[0]/M
    C=C*cmath.polar(M)[0]/M
    # print(A,B,C)
    return [A.real,B.real,C.real]
    # ya,yb,za,zb=geths(y,z,a)
    # hh=(ya+za)/2+ getmid(b,c,a)
    if x < hh-0.000001:
        return None
    # print("chsl1",x,y,z,a,b,c,hh, (x-hh)**2, (y-yb)**2+(z-zb)**2)
    return [hh,ya,za]

def chsl2(x,y,z,a,b,c):
    ba,bb,ca,cb=geths(b,c,a)
    if (x+ba)**2+bb**2 <= z**2+0.00001 and (x+ca)**2+cb**2 <= y**2+0.00001:
        # print("chsl2",x,y,z,a,b,c, (x+ba)**2+bb**2,y**2,(x+ca)**2+cb**2,z**2)
        return [x,x+ca,x+ba]
    return None

# def f(x,y,z,a,b,c):
#     th=angle(b,c,a)
    


def h(x,y,z,a,b,c):
    i=0
    for tt in [(x,y,z,a,b,c),(y,z,x,b,c,a),(z,x,y,c,a,b)]:
        if ans:=chsl2(*tt):
            for _ in range(3-i):
                ans=ans[-1:]+ans[:-1]
            return ans
        i += 1
    i=0
    for tt in [(x,y,z,a,b,c),(y,z,x,b,c,a),(z,x,y,c,a,b)]:
        if ans:=chsl1(*tt):
            for _ in range(3-i):
                ans=ans[-1:]+ans[:-1]
            return ans
        i += 1
    return None

def solve(x,y,z,a,b,c):
    ans = h(x,y,z,a,b,c)
    if ans:
        print(*[-V for V in ans])
        return
    ans=[]
    # brk=False
    for x,y,z,a,b,c in [(x,y,z,a,b,c),(y,z,x,b,c,a),(z,x,y,c,a,b)]:
        if a<abs(z-y):
            continue
        if not istri(z,y,a):
            print("WHAT")
            exit()
        lenzya=getmid(z,y,a)

        XXX=getmid(b,c,a)
        XM = XXX*2/3

        costh=getcos(x,XXX,lenzya)
        # if abs(costh)<0.00001:
        #     h(*og)
        #     brk=True
        #     break
        H=sqrt(x*x+XM*XM-2*x*XM*costh)
        ans.append(x*getcos(x,H,XM)*-1)
    # if brk:continue
    print(*ans)

def ok(x,y,z,a,b,c):
    if not istri(a,b,c):
        return False
    Cx=0
    Cy=0
    Bx=a
    By=0
    Ax=b*getcos(a,b,c)
    Ay=b*sin(acos(Ax/b))
    Mx=(Ax+Bx+Cx)/3
    My=(Ay+By+Cy)/3
    if (Cx-Mx)**2+(Cy-My)**2 >= z*z-0.00001:
        return False
    if (Bx-Mx)**2+(By-My)**2 >= y*y-0.00001:
        return False
    if (Ax-Mx)**2+(Ay-My)**2 >= x*x-0.00001:
        return False
    return True


for _ in range(int(input())):
    *og,=map(int,input().split())
    solve(*og)

# (base) lawry@larry:~/comp/nac-24/day-2-1/E$ python3 E.py < 1.in
# 1.1547005383792246 1.1547005383792246 1.1547005383792246
# 2.309401076758408 3.418538212273144 3.418538212273144
# (base) lawry@larry:~/comp/nac-24/day-2-1/E$ python3 E.py < 1.in
# -1.000000000000018 -1.000000000000018 -1.000000000000018
# -2.0 -2.9605409356365042 -2.9605409356365042
# (base) lawry@larry:~/comp/nac-24/day-2-1/E$ lp

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 4ms
memory: 11016kb

input:

2
1 1 1 1 1 1
2 3 3 1 1 1

output:

-0.8164965809277261 -0.8164965809277261 -0.8164965809277261
-2 -2.8660254037844384 -2.8660254037844384

result:

ok 6 numbers

Test #2:

score: -100
Dangerous Syscalls

input:

1000
21 2 14 12 13 4
29 19 13 15 10 17
29 24 15 29 24 23
29 17 30 18 9 25
27 24 30 16 4 15
28 13 17 12 21 16
16 22 10 22 15 8
15 23 24 23 27 13
26 3 27 15 16 17
5 8 20 17 6 12
24 14 13 15 19 13
27 22 18 18 23 30
22 18 14 11 29 28
7 13 22 22 17 11
19 9 16 22 20 17
21 14 20 6 29 25
20 10 19 9 27 27
17...

output:

-13.352348999857675 -2.9358567275868337 -2
-22.146476218003027 -16.07620470547688 -12.2418266590113
-28.027431433359673 -18.318582636182793 -8.243362186282255
-13.15931958432565 -26.882525397692707 -27.266119651334357
-26.53493336692567 -22.066632132649342 -29.616079568529667
-26.967804477491708 -12...

result: