結果

問題 No.245 貫け!
ユーザー rpy3cpprpy3cpp
提出日時 2015-07-17 23:30:58
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 149 ms / 5,000 ms
コード長 979 bytes
コンパイル時間 1,955 ms
コンパイル使用メモリ 86,628 KB
実行使用メモリ 76,624 KB
最終ジャッジ日時 2023-09-22 18:20:57
合計ジャッジ時間 3,437 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,052 KB
testcase_01 AC 72 ms
71,284 KB
testcase_02 AC 74 ms
71,120 KB
testcase_03 AC 74 ms
71,336 KB
testcase_04 AC 75 ms
71,140 KB
testcase_05 AC 73 ms
71,140 KB
testcase_06 AC 74 ms
71,224 KB
testcase_07 AC 72 ms
71,168 KB
testcase_08 AC 84 ms
75,756 KB
testcase_09 AC 94 ms
75,780 KB
testcase_10 AC 95 ms
75,820 KB
testcase_11 AC 111 ms
76,396 KB
testcase_12 AC 146 ms
76,428 KB
testcase_13 AC 140 ms
76,312 KB
testcase_14 AC 140 ms
76,364 KB
testcase_15 AC 148 ms
76,432 KB
testcase_16 AC 149 ms
76,336 KB
testcase_17 AC 139 ms
76,312 KB
testcase_18 AC 147 ms
76,344 KB
testcase_19 AC 147 ms
76,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def read_data():
    N = int(input())
    lines = []
    points = set()
    for i in range(N):
        a, b, c, d = map(int, input().split())
        lines.append((a, b, c, d))
        points.add((a, b))
        points.add((c, d))
    return N, lines, points

def solve(N, lines, points):
    points = list(points)
    record = 0
    for i, (x1, y1) in enumerate(points[:-1]):
        for j, (x2 ,y2) in enumerate(points[i+1:], i+1):
            n_cross = count_cross(x1, y1, x2, y2, lines)
            if n_cross > record:
                record = n_cross
    return record

def count_cross(x1, y1, x2, y2, lines):
    n_cross = 0
    dx = x2 - x1
    dy = y2 - y1
    for a, b, c, d in lines:
        if opposite_side(x1, y1, dx, dy, a, b, c, d):
            n_cross += 1
    return n_cross

def opposite_side(x1, y1, dx, dy, a, b, c, d):
    return  (dx*(b - y1) - dy*(a - x1)) * (dx*(d - y1) - dy*(c - x1)) <= 0

N, lines, points = read_data()
print(solve(N, lines, points))
0