結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー kichirb3
提出日時 2018-04-01 21:00:50
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 1,152 ms / 5,000 ms
コード長 1,552 bytes
コンパイル時間 304 ms
コンパイル使用メモリ 13,056 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-06-26 05:47:14
合計ジャッジ時間 22,539 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

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:])
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0