結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー kichirb3kichirb3
提出日時 2018-04-01 21:00:50
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 892 ms / 5,000 ms
コード長 1,552 bytes
コンパイル時間 241 ms
コンパイル使用メモリ 10,936 KB
実行使用メモリ 8,800 KB
最終ジャッジ日時 2023-09-08 12:34:49
合計ジャッジ時間 17,882 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 427 ms
8,688 KB
testcase_01 AC 830 ms
8,792 KB
testcase_02 AC 417 ms
8,728 KB
testcase_03 AC 444 ms
8,736 KB
testcase_04 AC 857 ms
8,728 KB
testcase_05 AC 866 ms
8,664 KB
testcase_06 AC 892 ms
8,768 KB
testcase_07 AC 891 ms
8,788 KB
testcase_08 AC 859 ms
8,800 KB
testcase_09 AC 869 ms
8,792 KB
testcase_10 AC 865 ms
8,632 KB
testcase_11 AC 286 ms
8,756 KB
testcase_12 AC 842 ms
8,656 KB
testcase_13 AC 641 ms
8,760 KB
testcase_14 AC 20 ms
8,616 KB
testcase_15 AC 883 ms
8,664 KB
testcase_16 AC 858 ms
8,764 KB
testcase_17 AC 827 ms
8,780 KB
testcase_18 AC 230 ms
8,708 KB
testcase_19 AC 873 ms
8,676 KB
testcase_20 AC 426 ms
8,704 KB
testcase_21 AC 387 ms
8,780 KB
testcase_22 AC 445 ms
8,664 KB
testcase_23 AC 445 ms
8,788 KB
testcase_24 AC 232 ms
8,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-
"""
No.55 正方形を描くだけの簡単なお仕事です。
https://yukicoder.me/problems/no/55

"""
import sys
from sys import stdin
from collections import Counter
input = stdin.readline


def is_valid(x1, y1, x2, y2, x3, y3, x4, y4):
    lines = []
    lines.append((x1 - x2)**2 + (y1 - y2)**2)
    lines.append((x1 - x3)**2 + (y1 - y3)**2)
    lines.append((x1 - x4)**2 + (y1 - y4)**2)
    lines.append((x2 - x1)**2 + (y2 - y1)**2)
    lines.append((x2 - x3)**2 + (y2 - y3)**2)
    lines.append((x2 - x4)**2 + (y2 - y4)**2)
    lines.append((x3 - x2)**2 + (y3 - y2)**2)
    lines.append((x3 - x1)**2 + (y3 - y1)**2)
    lines.append((x3 - x4)**2 + (y3 - y4)**2)
    lines.append((x4 - x2)**2 + (y4 - y2)**2)
    lines.append((x4 - x3)**2 + (y4 - y3)**2)
    lines.append((x4 - x1)**2 + (y4 - y1)**2)
    res = Counter(lines).most_common()
    if len(res) != 2:
        return False
    if res[0][1] != 8:
        return False
    if res[1][1] != 4:
        return False
    if abs(res[0][0]*2 - res[1][0]) > 0.00001:
        return False
    return True


def solve(x1, y1, x2, y2, x3, y3):
    for y in range(-200, 201, 1):
        for x in range(-200, 201, 1):
            if is_valid(x1, y1, x2, y2, x3, y3, x, y):
                return x, y
    return None, None


def main(args):
    x1, y1, x2, y2, x3, y3 = map(int, input().split())
    x4, y4 = solve(x1, y1, x2, y2, x3, y3)
    if x4 is None or y4 is None:
        print(-1)
    else:
        print(x4, y4)


if __name__ == '__main__':
    main(sys.argv[1:])
0