結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー pessimist
提出日時 2025-06-16 20:56:03
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 34 ms / 5,000 ms
コード長 554 bytes
コンパイル時間 700 ms
コンパイル使用メモリ 12,032 KB
実行使用メモリ 10,496 KB
最終ジャッジ日時 2025-06-16 20:56:06
合計ジャッジ時間 2,929 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read=sys.stdin.buffer.read

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_sq(p1,p2,p3,p4):
  d1=dist(p1,p2)
  d2=dist(p2,p3)
  d3=dist(p1,p3)
  d4=dist(p3,p4)
  d5=dist(p4,p1)
  d6=dist(p2,p4)
  return d1==d2==d4==d5!=d6 and d6==d3==2*d1

ans=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_sq(p,q,r,s):
        ans=s
        break
if ans is None: print(-1)
else: print(*ans)
0