結果

問題 No.635 自然門松列
ユーザー RyutoRyuto
提出日時 2018-03-05 16:15:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 85 ms / 650 ms
コード長 1,389 bytes
コンパイル時間 1,144 ms
コンパイル使用メモリ 86,680 KB
実行使用メモリ 75,920 KB
最終ジャッジ日時 2023-09-05 13:12:21
合計ジャッジ時間 3,641 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,344 KB
testcase_01 AC 73 ms
71,396 KB
testcase_02 AC 74 ms
71,188 KB
testcase_03 AC 74 ms
71,124 KB
testcase_04 AC 74 ms
71,024 KB
testcase_05 AC 84 ms
75,608 KB
testcase_06 AC 82 ms
75,704 KB
testcase_07 AC 84 ms
75,640 KB
testcase_08 AC 74 ms
71,132 KB
testcase_09 AC 75 ms
71,368 KB
testcase_10 AC 82 ms
75,608 KB
testcase_11 AC 85 ms
75,396 KB
testcase_12 AC 83 ms
75,920 KB
testcase_13 AC 82 ms
75,744 KB
testcase_14 AC 81 ms
75,724 KB
testcase_15 AC 72 ms
71,256 KB
testcase_16 AC 74 ms
71,072 KB
testcase_17 AC 82 ms
75,656 KB
testcase_18 AC 82 ms
75,580 KB
testcase_19 AC 79 ms
75,752 KB
testcase_20 AC 82 ms
75,516 KB
testcase_21 AC 82 ms
75,760 KB
testcase_22 AC 81 ms
75,580 KB
testcase_23 AC 82 ms
75,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python

def ChkKado(x, y, z):
    if x != y != z != x:
        if x > y < z or x < y > z:
            return True
    return False


def MkRange1(d0, dt):
    tmax = float('inf')
    tmin = 0.0

    if dt == 0:
        if d0 <= 0:
            tmax = -1
    elif dt > 0:
        tmin = max(0.0, -d0/dt)
    elif dt < 0:
        tmax = -d0/dt

    return [tmin, tmax]


def MkRange2(d0, dt):
    tmax = float('inf')
    tmin = 0.0

    if dt == 0:
        if d0 >= 0:
            tmax = -1
    elif dt > 0:
        tmax = -d0/dt
    elif dt < 0:
        tmin = max(0.0, -d0/dt)

    return [tmin, tmax]


def ChkAbKado(x0, y0, z0, xt, yt, zt):
    dyx = [y0 - x0, yt - xt]
    dyz = [y0 - z0, yt - zt]
    dzx = [z0 - x0, zt - xt]
    yxrange1 = MkRange1(*dyx)
    yzrange1 = MkRange1(*dyz)
    yxrange2 = MkRange2(*dyx)
    yzrange2 = MkRange2(*dyz)
    if dzx == [0.0, 0.0]:
        return False
    elif max(yxrange1[0], yzrange1[0], 0.0) < min(yxrange1[1], yzrange1[1]):
        return True
    elif max(yxrange2[0], yzrange2[0], 0.0) < min(yxrange2[1], yzrange2[1]):
        return True
    else:
        return False


N = int(input())
tcases = []
for i in range(N):
    tcases.append([int(x) for x in input().split()])

for tcase in tcases:
    if ChkKado(*tcase[:3]):
        print('YES')
    elif ChkAbKado(*tcase):
        print('YES')
    else:
        print('NO')
0