結果
| 問題 | 
                            No.245 貫け!
                             | 
                    
| コンテスト | |
| ユーザー | 
                             lam6er
                         | 
                    
| 提出日時 | 2025-03-31 17:33:32 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 117 ms / 5,000 ms | 
| コード長 | 1,044 bytes | 
| コンパイル時間 | 215 ms | 
| コンパイル使用メモリ | 82,188 KB | 
| 実行使用メモリ | 71,036 KB | 
| 最終ジャッジ日時 | 2025-03-31 17:34:07 | 
| 合計ジャッジ時間 | 2,557 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 16 | 
ソースコード
n = int(input())
segments = []
points = []
for _ in range(n):
    a, b, c, d = map(int, input().split())
    segments.append(((a, b), (c, d)))
    points.append((a, b))
    points.append((c, d))
max_count = 0
for i in range(len(points)):
    for j in range(i + 1, len(points)):
        p1 = points[i]
        p2 = points[j]
        if p1 == p2:
            continue
        # Compute line equation ax + by + c = 0
        a_coeff = p1[1] - p2[1]
        b_coeff = p2[0] - p1[0]
        c_coeff = p1[0] * p2[1] - p2[0] * p1[1]
        current = 0
        for seg in segments:
            (x3, y3), (x4, y4) = seg
            v3 = a_coeff * x3 + b_coeff * y3 + c_coeff
            v4 = a_coeff * x4 + b_coeff * y4 + c_coeff
            if v3 == 0 or v4 == 0:
                current += 1
            elif (v3 < 0 and v4 > 0) or (v3 > 0 and v4 < 0):
                current += 1
        if current > max_count:
            max_count = current
# Also check all lines that are exactly the line of a segment (handled by endpoints)
print(max_count)
            
            
            
        
            
lam6er