QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#55079#2290. Kinking CablesMIT01#WA 17ms8636kbPython31.2kb2022-10-12 09:11:282022-10-12 09:11:30

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-12 09:11:30]
  • 评测
  • 测评结果:WA
  • 用时:17ms
  • 内存:8636kb
  • [2022-10-12 09:11:28]
  • 提交

answer

import sys

def dist(A, B):
    return ((A[0]-B[0])**2 + (A[1]-B[1])**2) ** 0.5

n, m = map(int, input().split())
l = float(input())

goal = (n, m)

at = (0, 0)
far = 0
ans = []

def get_pt(d, sign):
    mid = (at[0] + goal[0]) / 2, (at[1] + goal[1]) / 2
    perp = (at[1] - goal[1]), (goal[0] - at[0])
    l = dist((0, 0), perp)
    perp = perp[0]/l, perp[1]/l
    return mid[0] + sign * d * perp[0], mid[1] + sign * d * perp[1]

def finish_off(sign):
    lo, hi = 0, n + m
    for i in range(100):
        mid = (lo+hi) / 2
        pt = get_pt(mid, sign)
        if far + dist(at, pt) + dist(pt, goal) <= l:
            lo = mid
        else:
            hi = mid
    pt = get_pt(lo, sign)
    ans.append(pt)
    ans.append(goal)

def goto(dest, sign):
    if far + dist(at, dest) + dist(dest, goal) <= l:
        ans.append(dest)
        return dest, far + dist(at, dest)
    else:
        finish_off(sign)
        output()
        return None, None

def output():
    print(len(ans))
    for p in ans:
        print(*p)
    sys.exit(0)

for x in range(n+1):
    if at is not None:
        at, far = goto((x, 0), -1)
    if at is not None:
        at, far = goto((x, m), 1)
output()

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 17ms
memory: 8528kb

input:

79 78
1980.7712136406

output:

27
0 0
0 78
1 0
1 78
2 0
2 78
3 0
3 78
4 0
4 78
5 0
5 78
6 0
6 78
7 0
7 78
8 0
8 78
9 0
9 78
10 0
10 78
11 0
11 78
12 0
32.13619845010919 50.479162869778
79 78

result:

ok correct

Test #2:

score: 0
Accepted
time: 7ms
memory: 8612kb

input:

33 65
1947.7601065763

output:

32
0 0
0 65
1 0
1 65
2 0
2 65
3 0
3 65
4 0
4 65
5 0
5 65
6 0
6 65
7 0
7 65
8 0
8 65
9 0
9 65
10 0
10 65
11 0
11 65
12 0
12 65
13 0
13 65
14 0
14 65
23.5 35.14901252858663
33 65

result:

ok correct

Test #3:

score: 0
Accepted
time: 5ms
memory: 8592kb

input:

51 51
555.0803652025

output:

12
0 0
0 51
1 0
1 51
2 0
2 51
3 0
3 51
4 0
4 51
27.5 9.12249074899323
51 51

result:

ok correct

Test #4:

score: 0
Accepted
time: 13ms
memory: 8564kb

input:

49 2
67.3588717350

output:

14
0 0
0 2
1 0
1 2
2 0
2 2
3 0
3 2
4 0
4 2
5 0
5 2
27.0 0.016147926339765473
49 2

result:

ok correct

Test #5:

score: 0
Accepted
time: 15ms
memory: 8636kb

input:

37 48
1713.3643608504

output:

38
0 0
0 48
1 0
1 48
2 0
2 48
3 0
3 48
4 0
4 48
5 0
5 48
6 0
6 48
7 0
7 48
8 0
8 48
9 0
9 48
10 0
10 48
11 0
11 48
12 0
12 48
13 0
13 48
14 0
14 48
15 0
15 48
16 0
16 48
17 0
17 48
27.0 34.75805278583974
37 48

result:

ok correct

Test #6:

score: 0
Accepted
time: 5ms
memory: 8532kb

input:

51 79
820.1218304546

output:

12
0 0
0 79
1 0
1 79
2 0
2 79
3 0
3 79
4 0
4 79
27.5 29.773356838067684
51 79

result:

ok correct

Test #7:

score: 0
Accepted
time: 6ms
memory: 8580kb

input:

6 8
37.5338494218

output:

6
0 0
0 8
1 0
1 8
3.5 1.7453261032737748
6 8

result:

ok correct

Test #8:

score: 0
Accepted
time: 9ms
memory: 8636kb

input:

5 5
7.1908428511

output:

3
0 0
2.037909517895036 2.962090482104964
5 5

result:

ok correct

Test #9:

score: -100
Wrong Answer
time: 2ms
memory: 8584kb

input:

5 4
8.3927665498

output:

3
0 0
0.8052871209598473 4.118391098800191
5 4

result:

wrong answer Double parameter [name=y_i] equals to 4.11839, violates the range [0, 4]