結果

問題 No.2355 Unhappy Back Dance
ユーザー lam6er
提出日時 2025-03-20 20:26:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,449 ms / 6,000 ms
コード長 1,060 bytes
コンパイル時間 187 ms
コンパイル使用メモリ 82,360 KB
実行使用メモリ 83,000 KB
最終ジャッジ日時 2025-03-20 20:27:35
合計ジャッジ時間 22,137 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import math

def main():
    input = sys.stdin.read().split()
    idx = 0
    N = int(input[idx])
    idx += 1
    points = []
    for _ in range(N):
        x = int(input[idx])
        y = int(input[idx+1])
        points.append((x, y))
        idx += 2
    
    result = 0
    for i in range(N):
        xi, yi = points[i]
        dir_counts = {}
        for j in range(N):
            if i == j:
                continue
            xj, yj = points[j]
            dx = xj - xi
            dy = yj - yi
            g = math.gcd(abs(dx), abs(dy))
            if g == 0:
                continue  # Not possible as per problem constraints
            reduced = (dx // g, dy // g)
            if reduced in dir_counts:
                dir_counts[reduced] += 1
            else:
                dir_counts[reduced] = 1
        # Check if any direction has at least two points
        for count in dir_counts.values():
            if count >= 2:
                result += 1
                break
    print(result)

if __name__ == '__main__':
    main()
0