結果

問題 No.245 貫け!
ユーザー rlangevinrlangevin
提出日時 2023-10-23 12:43:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 111 ms / 5,000 ms
コード長 793 bytes
コンパイル時間 223 ms
コンパイル使用メモリ 81,836 KB
実行使用メモリ 73,164 KB
最終ジャッジ日時 2023-10-23 12:43:52
合計ジャッジ時間 2,648 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,636 KB
testcase_01 AC 36 ms
53,636 KB
testcase_02 AC 37 ms
53,636 KB
testcase_03 AC 36 ms
53,636 KB
testcase_04 AC 36 ms
53,636 KB
testcase_05 AC 37 ms
53,636 KB
testcase_06 AC 37 ms
53,636 KB
testcase_07 AC 40 ms
53,636 KB
testcase_08 AC 53 ms
66,416 KB
testcase_09 AC 65 ms
71,116 KB
testcase_10 AC 68 ms
71,116 KB
testcase_11 AC 81 ms
73,164 KB
testcase_12 AC 111 ms
73,164 KB
testcase_13 AC 106 ms
72,648 KB
testcase_14 AC 109 ms
73,164 KB
testcase_15 AC 102 ms
73,164 KB
testcase_16 AC 104 ms
72,632 KB
testcase_17 AC 106 ms
72,632 KB
testcase_18 AC 108 ms
72,632 KB
testcase_19 AC 104 ms
73,164 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
X = []
a, b, c, d = [-1] * N, [-1] * N, [-1] * N, [-1] * N
for i in range(N):
    a[i], b[i], c[i], d[i] = map(int, input().split())
    X.append((a[i], b[i]))
    X.append((c[i], d[i]))

def f(x1, y1, x2, y2, x3, y3):
    x12 = x2 - x1
    x13 = x3 - x1
    y12 = y2 - y1
    y13 = y3 - y1
    return x12 * y13 - x13 * y12

def solve(x1, y1, x2, y2, x3, y3, x4, y4):
    if f(x1, y1, x2, y2, x3, y3) * f(x1, y1, x2, y2, x4, y4) > 0:
        return 0
    return 1

ans = 0
for i in range(2 * N):
    for j in range(i + 1, 2 * N):
        x1, y1 = X[i]
        x2, y2 = X[j]
        if x1 == x2 and y1 == y2:
            continue
        val = 0
        for k in range(N):
            val += solve(x1, y1, x2, y2, a[k], b[k], c[k], d[k])
        ans = max(ans, val)

print(ans)
0