結果
問題 |
No.55 正方形を描くだけの簡単なお仕事です。
|
ユーザー |
![]() |
提出日時 | 2020-02-02 13:55:33 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 32 ms / 5,000 ms |
コード長 | 660 bytes |
コンパイル時間 | 220 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-09-18 20:43:59 |
合計ジャッジ時間 | 1,964 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 |
ソースコード
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import itertools x1,y1,x2,y2,x3,y3 = map(int,read().split()) p1 = (x1,y1) p2 = (x2,y2) p3 = (x3,y3) def dist(p,q): return (p[0]-q[0])**2 + (p[1]-q[1])**2 def is_square(p1,p2,p3,p4): # この順に平行四辺形を仮定 d1 = dist(p1,p2) d2 = dist(p2,p3) d3 = dist(p1,p3) return (d1==d2) and (d3==d1*2) answer = None for p,q,r in itertools.permutations([p1,p2,p3]): s = tuple(p[i]+r[i]-q[i] for i in [0,1]) if is_square(p,q,r,s): answer = s if answer is None: print(-1) else: print(*answer)