結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー gemmarogemmaro
提出日時 2020-06-20 09:19:01
言語 Ruby
(3.3.0)
結果
AC  
実行時間 84 ms / 5,000 ms
コード長 475 bytes
コンパイル時間 37 ms
コンパイル使用メモリ 11,468 KB
実行使用メモリ 15,372 KB
最終ジャッジ日時 2023-09-16 16:58:41
合計ジャッジ時間 3,255 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
15,304 KB
testcase_01 AC 83 ms
15,372 KB
testcase_02 AC 83 ms
15,344 KB
testcase_03 AC 80 ms
15,264 KB
testcase_04 AC 80 ms
15,100 KB
testcase_05 AC 80 ms
15,264 KB
testcase_06 AC 83 ms
15,136 KB
testcase_07 AC 81 ms
15,344 KB
testcase_08 AC 82 ms
15,180 KB
testcase_09 AC 80 ms
15,128 KB
testcase_10 AC 81 ms
15,260 KB
testcase_11 AC 81 ms
15,308 KB
testcase_12 AC 81 ms
15,136 KB
testcase_13 AC 81 ms
15,196 KB
testcase_14 AC 82 ms
15,128 KB
testcase_15 AC 81 ms
15,328 KB
testcase_16 AC 81 ms
15,148 KB
testcase_17 AC 80 ms
15,276 KB
testcase_18 AC 80 ms
15,044 KB
testcase_19 AC 80 ms
15,056 KB
testcase_20 AC 81 ms
15,104 KB
testcase_21 AC 80 ms
15,168 KB
testcase_22 AC 80 ms
15,104 KB
testcase_23 AC 80 ms
15,184 KB
testcase_24 AC 80 ms
15,176 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

# frozen_string_literal: true

def solve
  x = [[X1, Y1], [X2, Y2], [X3, Y3]].permutation.find do |p1, p2, p3|
    a = (p1[0] - p2[0])**2 + (p1[1] - p2[1])**2
    b = (p2[0] - p3[0])**2 + (p2[1] - p3[1])**2
    c = (p3[0] - p1[0])**2 + (p3[1] - p1[1])**2
    a == b && a * 2 == c
  end
  if x.nil?
    -1
  else
    a = x[0][0] - x[1][0] + x[2][0]
    b = x[0][1] - x[1][1] + x[2][1]
    [a, b].join(' ')
  end
end

X1, Y1, X2, Y2, X3, Y3 = gets.split.map(&:to_i)

puts solve
0