結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー suppy193suppy193
提出日時 2016-11-02 10:16:07
言語 Ruby
(3.3.0)
結果
AC  
実行時間 81 ms / 5,000 ms
コード長 808 bytes
コンパイル時間 297 ms
コンパイル使用メモリ 11,308 KB
実行使用メモリ 15,344 KB
最終ジャッジ日時 2023-08-16 12:35:31
合計ジャッジ時間 3,406 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
15,036 KB
testcase_01 AC 78 ms
15,244 KB
testcase_02 AC 77 ms
15,308 KB
testcase_03 AC 80 ms
15,180 KB
testcase_04 AC 79 ms
15,288 KB
testcase_05 AC 81 ms
15,308 KB
testcase_06 AC 78 ms
15,344 KB
testcase_07 AC 79 ms
15,316 KB
testcase_08 AC 80 ms
15,036 KB
testcase_09 AC 79 ms
15,036 KB
testcase_10 AC 79 ms
15,340 KB
testcase_11 AC 78 ms
15,156 KB
testcase_12 AC 78 ms
15,232 KB
testcase_13 AC 78 ms
15,312 KB
testcase_14 AC 79 ms
15,076 KB
testcase_15 AC 79 ms
15,164 KB
testcase_16 AC 77 ms
15,092 KB
testcase_17 AC 78 ms
15,248 KB
testcase_18 AC 78 ms
15,140 KB
testcase_19 AC 79 ms
15,120 KB
testcase_20 AC 78 ms
15,164 KB
testcase_21 AC 78 ms
15,044 KB
testcase_22 AC 78 ms
15,120 KB
testcase_23 AC 79 ms
15,088 KB
testcase_24 AC 78 ms
15,312 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

pos = gets.strip.split(' ').map(&:to_i)
x1 = pos[0]
y1 = pos[1]
x2 = pos[2]
y2 = pos[3]
x3 = pos[4]
y3 = pos[5]


def dis2(pos1, pos2)
	(pos1[0] - pos2[0]) ** 2 + (pos1[1] - pos2[1]) ** 2
end

def scalar(x1, y1, x2, y2, x3, y3)
	(x2 - x1) * (x3 - x1) + (y2 - y1) * (y3 - y1)
end


dis12 = dis2([x1, y1], [x2, y2])
#p dis12
dis23 = dis2([x2, y2], [x3, y3])
#p dis23
dis31 = dis2([x3, y3], [x1, y1])
#p dis31

if dis12 == dis23 && dis23 == dis31
	puts "-1"
	exit
end
if dis12 != dis23 && dis23 != dis31 && dis31 != dis12
	puts "-1"
	exit
end

if dis23 == dis31
	x1, x2, x3 = x2, x3, x1
	y1, y2, y3 = y2, y3, y1
end
if dis31 == dis12
	x1, x2, x3 = x3, x1, x2
	y1, y2, y3 = y3, y1, y2
end
if scalar(x2, y2, x1, y1, x3, y3) == 0
	x4 = x1 + (x3 - x2)
	y4 = y1 + (y3 - y2)
	print "#{x4} #{y4}\n"
else
	puts "-1"
end
0