結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー c-yanc-yan
提出日時 2021-03-29 09:46:25
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 18 ms / 5,000 ms
コード長 830 bytes
コンパイル時間 196 ms
コンパイル使用メモリ 10,884 KB
実行使用メモリ 8,900 KB
最終ジャッジ日時 2023-08-19 16:03:34
合計ジャッジ時間 2,179 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,584 KB
testcase_01 AC 17 ms
8,804 KB
testcase_02 AC 17 ms
8,588 KB
testcase_03 AC 17 ms
8,692 KB
testcase_04 AC 17 ms
8,780 KB
testcase_05 AC 18 ms
8,760 KB
testcase_06 AC 17 ms
8,616 KB
testcase_07 AC 17 ms
8,592 KB
testcase_08 AC 16 ms
8,808 KB
testcase_09 AC 16 ms
8,580 KB
testcase_10 AC 17 ms
8,596 KB
testcase_11 AC 17 ms
8,744 KB
testcase_12 AC 17 ms
8,812 KB
testcase_13 AC 16 ms
8,744 KB
testcase_14 AC 17 ms
8,584 KB
testcase_15 AC 17 ms
8,812 KB
testcase_16 AC 16 ms
8,576 KB
testcase_17 AC 17 ms
8,576 KB
testcase_18 AC 17 ms
8,724 KB
testcase_19 AC 17 ms
8,836 KB
testcase_20 AC 17 ms
8,804 KB
testcase_21 AC 17 ms
8,584 KB
testcase_22 AC 17 ms
8,900 KB
testcase_23 AC 17 ms
8,592 KB
testcase_24 AC 17 ms
8,744 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import atan2, pi, sin, cos, sqrt

X1, Y1, X2, Y2, X3, Y3 = map(int, input().split())


def round(x):
    if x < 0:
        return int(x - 0.5)
    return int(x + 0.5)


def f(x1, y1, x2, y2, x3, y3):
    x, y = (x1 + x2) / 2, (y1 + y2) / 2
    r = sqrt((x - x1) * (x - x1) + (y - y1) * (y - y1))
    t = atan2(y - y1, x - x1)
    x4 = round(x + r * cos(t + pi / 2))
    y4 = round(y + r * sin(t + pi / 2))
    x5 = round(x + r * cos(t - pi / 2))
    y5 = round(y + r * sin(t - pi / 2))
    if x3 == x4 and y3 == y4:
        return x5, y5
    elif x3 == x5 and y3 == y5:
        return x4, y4
    return None


result = f(X1, Y1, X2, Y2, X3, Y3)
if result is None:
    result = f(X1, Y1, X3, Y3, X2, Y2)
if result is None:
    result = f(X2, Y2, X3, Y3, X1, Y1)

if result is None:
    print(-1)
else:
    print(*result)
0