結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー 小指が強い人小指が強い人
提出日時 2016-01-01 02:06:24
言語 Ruby
(3.3.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 622 bytes
コンパイル時間 275 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2024-04-16 22:20:16
合計ジャッジ時間 3,419 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
12,416 KB
testcase_01 AC 85 ms
12,160 KB
testcase_02 AC 86 ms
12,160 KB
testcase_03 AC 91 ms
12,160 KB
testcase_04 WA -
testcase_05 AC 88 ms
12,288 KB
testcase_06 AC 89 ms
12,160 KB
testcase_07 AC 86 ms
12,160 KB
testcase_08 AC 87 ms
12,416 KB
testcase_09 AC 86 ms
12,160 KB
testcase_10 AC 87 ms
12,416 KB
testcase_11 AC 87 ms
12,160 KB
testcase_12 AC 89 ms
12,416 KB
testcase_13 AC 92 ms
12,288 KB
testcase_14 AC 87 ms
12,160 KB
testcase_15 AC 92 ms
12,160 KB
testcase_16 AC 88 ms
12,416 KB
testcase_17 AC 87 ms
12,416 KB
testcase_18 AC 90 ms
12,160 KB
testcase_19 AC 93 ms
12,288 KB
testcase_20 AC 91 ms
12,032 KB
testcase_21 AC 90 ms
12,160 KB
testcase_22 AC 87 ms
12,160 KB
testcase_23 AC 86 ms
12,160 KB
testcase_24 AC 88 ms
12,288 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:26: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Main.rb:7: warning: assigned but unused variable - vs1
Main.rb:8: warning: assigned but unused variable - vs2
Main.rb:9: warning: assigned but unused variable - ct
Syntax OK

ソースコード

diff #

coord = Struct.new(:x, :y)
s = gets.split.map(&:to_i)
a = Array.new
a.push(coord.new(s[0], s[1]))
a.push(coord.new(s[2], s[3]))
a.push(coord.new(s[4], s[5]))
vs1 = coord.new
vs2 = coord.new
ct = -1
3.times do |i|
    i1 = (i + 1) % 3
    i2 = (i + 2) % 3
    v1 = coord.new(a[i1].x - a[i].x, a[i1].y - a[i].y)
    v2 = coord.new(a[i2].x - a[i].x, a[i2].y - a[i].y)
    c = v1.x * v1.y + v2.x * v2.y
    if c == 0
        d1 = v1.x ** 2 + v1.y ** 2
        d2 = v2.x ** 2 + v2.y ** 2
        if d1 != d2
            break
        end
        print a[i1].x + v2.x, " ", a[i1].y + v2.y, "\n"
        exit
    end
end
puts -1
0