Problem p03006 (python)

Fixed submission:

N = int(input())

xy = []
for i in range(N):
    xi, yi = map(int, input().split())
    xy.append((xi, yi))


vectors = []

x1, x2, y1, y2, xd, yd = 0, 0, 0, 0, 0, 0
for i in range(N):
    for j in range(i+1, N):
        x1, y1 = xy[i]
        x2, y2 = xy[j]

        vectors.append((x1-x2, y1-y2))
        vectors.append((x2-x1, y2-y1))

vectors.sort(key=lambda x: x[1])
vectors.sort()

frequencies_dic = {}
M = len(vectors)
for i in range(M):
    x, y = vectors[i]
    if (x, y) not in frequencies_dic:
        frequencies_dic[(x,y)] = 1
    else:
        frequencies_dic[(x,y)] += 1
if N == 1:
    print(1)
else:
    zeros = max(list(frequencies_dic.values()))
    ans = N - zeros
    print(ans)

Buggy submission (verdict: Runtime Error):

N = int(input())

xy = []
for i in range(N):
    xi, yi = map(int, input().split())
    xy.append((xi, yi))

t = 10**9
vectors = []

x1, x2, y1, y2, xd, yd = 0, 0, 0, 0, 0, 0
for i in range(N):
    for j in range(i+1, N):
        x1, y1 = xy[i]
        x2, y2 = xy[j]

        vectors.append((x1-x2, y1-y2))
        vectors.append((x2-x1, y2-y1))

vectors.sort(key=lambda x: x[1])
vectors.sort()

frequencies_dic = {}
M = len(vectors)
for i in range(M):
    x, y = vectors[i]
    if (x, y) not in frequencies_dic:
        frequencies_dic[(x,y)] = 1
    else:
        frequencies_dic[(x,y)] += 1

zeros = max(list(frequencies_dic.values()))
ans = N - zeros
print(ans)

Buggy submission (verdict: Runtime Error):

N = int(input())

xy = []
for i in range(N):
    xi, yi = map(int, input().split())
    xy.append((xi, yi))

t = 10**9
vectors = []

x1, x2, y1, y2, xd, yd = 0, 0, 0, 0, 0, 0
for i in range(N):
    for j in range(i+1, N):
        x1, y1 = xy[i]
        x2, y2 = xy[j]
        if x1 > x2:
            xd = x1 - x2
        elif x2 > x1:
            xd = x2 - x1
        else:
            continue
        if y1 > y2:
            yd = y1 - y2
        elif y2 > y1:
            yd = y2 - y1
        else:
            continue

        vectors.append((xd, yd))

vectors.sort(key=lambda x: x[1])
vectors.sort()

frequencies_dic = {}
M = len(vectors)
for i in range(M):
    x, y = vectors[i]
    if (x, y) not in frequencies_dic:
        frequencies_dic[(x,y)] = 1
    else:
        frequencies_dic[(x,y)] += 1

zeros = max(list(frequencies_dic.values()))
ans = N - zeros
print(ans)

Buggy submission (verdict: Runtime Error):

N = int(input())

#x_max, y_max = 0, 0

xy = []
for i in range(N):
    xi, yi = map(int, input().split())
    xy.append((xi, yi))

t = 10**9
vectors = []

x1, x2, y1, y2, xd, yd = 0, 0, 0, 0, 0, 0
for i in range(N):
    for j in range(i+1, N):
        x1, y1 = xy[i]
        x2, y2 = xy[j]
        if x1 > x2:
            xd = x1 - x2
        elif x2 > x1:
            xd = x2 - x1
        else:
            continue
        if y1 > y2:
            yd = y1 - y2
        elif y2 > y1:
            yd = y2 - y1
        else:
            continue

        vectors.append((xd, yd))

vectors.sort(key=lambda x: x[1])
vectors.sort()

frequencies_dic = {}
M = len(vectors)
for i in range(M):
    x, y = vectors[i]
    if (x, y) not in frequencies_dic:
        frequencies_dic[(x,y)] = 1
    else:
        frequencies_dic[(x,y)] += 1

ans = max(list(frequencies_dic.values()))
print(ans)