【AtCoder参加記録】ABC224【AB2完】
残り25分ほどで、C問題で以下のコードでTLEとなり終了まで原因がわからずAB2完で終了しました。 終了後に気づきましたがPython3で提出してしまっておりPyPy3であればACでした。
25分もあったので何故気づかなかったのかと思いますが、今後は同じミスがないようにしたいと思います。
B問題に30分ほどかかってしまった点も反省です。
import itertools N = int(input()) m = [] for i in range(N): m.append(list(map(int, input().split()))) count = 0 for i1, i2, i3 in itertools.combinations(list(range(1, N+1)), 3): x1, y1 = m[i1-1] x2, y2 = m[i2-1] x3, y3 = m[i3-1] if (x2 - x1) != 0: d1 = (y2 - y1) / (x2 - x1) else: d1 = 0 if (x3 - x1) != 0: d2 = (y3 - y1) / (x3 - x1) else: d2 = 0 if (x3 - x2) != 0: d3 = (y3 - y2) / (x3 - x2) else: d3 = 0 if d1 == d2 and d1 == d3: continue else: count+=1 print(int(count))