結果
問題 | No.55 正方形を描くだけの簡単なお仕事です。 |
ユーザー |
![]() |
提出日時 | 2016-08-11 15:08:45 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 104 ms / 5,000 ms |
コード長 | 1,121 bytes |
コンパイル時間 | 183 ms |
コンパイル使用メモリ | 7,552 KB |
実行使用メモリ | 13,440 KB |
最終ジャッジ日時 | 2024-11-14 13:55:34 |
合計ジャッジ時間 | 3,588 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 |
コンパイルメッセージ
Syntax OK
ソースコード
#!/usr/bin/env rubyrequire "matrix"EPS = 1e-8def rotation_matrix(angle)c = Math.cos angles = Math.sin anglem = Matrix[[c, -s, 0], [s, c, 0], [0, 0, 1]]return menddef translation_matrix(delta)m = Matrix[[1, 0, delta[0]], [0, 1, delta[1]], [0, 0, 1]]return menddef rotate_around(center, point, angle)m = translation_matrix(center)m *= rotation_matrix(angle)m *= translation_matrix([-center[0], -center[1]])v = Vector[*point, 1]a = m * vreturn Vector[a[0], a[1]]enddef find_last_point(point1, point2, point3)ps = [point1, point2, point3]ps.permutation(3) {|p1, p2, p3|q3 = rotate_around(p2, p1, Math::PI / 2.0)return rotate_around(p3, p2, Math::PI / 2.0) if (p3 - q3).r < EPS}return nilenddef main()x1, y1, x2, y2, x3, y3 = gets.split.map(&:to_i)point1 = Vector[x1, y1]point2 = Vector[x2, y2]point3 = Vector[x3, y3]ans = find_last_point(point1, point2, point3)if ans != nilputs ans.map(&:round).to_a.join(" ")elseputs (-1)endendmain