結果
| 問題 |
No.55 正方形を描くだけの簡単なお仕事です。
|
| コンテスト | |
| ユーザー |
suppy193
|
| 提出日時 | 2016-11-02 10:16:07 |
| 言語 | Ruby (3.4.1) |
| 結果 |
AC
|
| 実行時間 | 80 ms / 5,000 ms |
| コード長 | 808 bytes |
| コンパイル時間 | 79 ms |
| コンパイル使用メモリ | 7,424 KB |
| 実行使用メモリ | 12,288 KB |
| 最終ジャッジ日時 | 2024-11-25 01:25:10 |
| 合計ジャッジ時間 | 3,147 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 21 |
コンパイルメッセージ
Syntax OK
ソースコード
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
suppy193