結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー kichirb3kichirb3
提出日時 2018-04-01 20:59:20
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,552 bytes
コンパイル時間 140 ms
コンパイル使用メモリ 10,908 KB
実行使用メモリ 8,796 KB
最終ジャッジ日時 2023-09-08 12:33:37
合計ジャッジ時間 6,392 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
8,648 KB
testcase_01 AC 230 ms
8,632 KB
testcase_02 AC 120 ms
8,732 KB
testcase_03 AC 135 ms
8,632 KB
testcase_04 AC 226 ms
8,636 KB
testcase_05 AC 227 ms
8,588 KB
testcase_06 AC 237 ms
8,588 KB
testcase_07 AC 233 ms
8,648 KB
testcase_08 AC 234 ms
8,696 KB
testcase_09 AC 234 ms
8,640 KB
testcase_10 AC 234 ms
8,692 KB
testcase_11 AC 56 ms
8,620 KB
testcase_12 AC 227 ms
8,748 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 238 ms
8,780 KB
testcase_16 WA -
testcase_17 AC 224 ms
8,636 KB
testcase_18 AC 20 ms
8,592 KB
testcase_19 AC 234 ms
8,632 KB
testcase_20 AC 123 ms
8,632 KB
testcase_21 AC 105 ms
8,640 KB
testcase_22 WA -
testcase_23 AC 134 ms
8,652 KB
testcase_24 WA -
権限があれば一括ダウンロードができます

ソースコード

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(-100, 101, 1):
        for x in range(-100, 101, 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