結果
問題 | No.55 正方形を描くだけの簡単なお仕事です。 |
ユーザー |
![]() |
提出日時 | 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]) ** 2enddef scalar(x1, y1, x2, y2, x3, y3)(x2 - x1) * (x3 - x1) + (y2 - y1) * (y3 - y1)enddis12 = dis2([x1, y1], [x2, y2])#p dis12dis23 = dis2([x2, y2], [x3, y3])#p dis23dis31 = dis2([x3, y3], [x1, y1])#p dis31if dis12 == dis23 && dis23 == dis31puts "-1"exitendif dis12 != dis23 && dis23 != dis31 && dis31 != dis12puts "-1"exitendif dis23 == dis31x1, x2, x3 = x2, x3, x1y1, y2, y3 = y2, y3, y1endif dis31 == dis12x1, x2, x3 = x3, x1, x2y1, y2, y3 = y3, y1, y2endif scalar(x2, y2, x1, y1, x3, y3) == 0x4 = x1 + (x3 - x2)y4 = y1 + (y3 - y2)print "#{x4} #{y4}\n"elseputs "-1"end