結果

問題 No.2355 Unhappy Back Dance
ユーザー AngrySadEight
提出日時 2023-04-13 01:45:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 3,019 ms / 6,000 ms
コード長 958 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 201,916 KB
最終ジャッジ日時 2024-10-10 12:36:23
合計ジャッジ時間 41,357 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

def my_gcd(a, b):
    if b == 0:
        return a
    else:
        return my_gcd(b, a % b)

N = int(input())
X = []
Y = []
for i in range(N):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)
pos = [False for _ in range(N)]
for i in range(N):
    lst = []
    st = set()
    for j in range(N):
        if i == j:
            lst.append([-1, -1])
            continue
        dx = X[j] - X[i]
        dy = Y[j] - Y[i]
        if dx == 0:
            dy = dy // abs(dy)
        elif dy == 0:
            dx = dx // abs(dx)
        else:
            g = my_gcd(max(abs(dx), abs(dy)), min(abs(dx), abs(dy)))
            dx = dx // g
            dy = dy // g
        lst.append([dx, dy])
        st.add((dx, dy))
    for j in range(N):
        if i == j:
            continue
        lst2 = (lst[j][0] * -1, lst[j][1] * -1)
        if lst2 in st:
            pos[j] = True
ans = 0
for i in range(N):
    if pos[i]:
        ans += 1
print(ans)
0