結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー simansiman
提出日時 2016-03-27 04:36:32
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 714 bytes
コンパイル時間 200 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2024-04-10 02:31:55
合計ジャッジ時間 3,737 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

class Yukicoder
  def initialize
    x1, y1, x2, y2, x3, y3 = gets.chomp.split.map(&:to_i)

    coords = [[x1,y1],[x2,y2],[x3,y3]]

    coords.permutation do |list|
      x1, y1, x2, y2, x3, y3 = *list.flatten
      d1 = Math.sqrt((x2-x1) ** 2 + (y2-y1) ** 2)
      d2 = Math.sqrt((x2-x3) ** 2 + (y2-y3) ** 2)

      if d1 == d2
        -100.upto(100) do |y|
          -100.upto(100) do |x|
            d3 = Math.sqrt((x-x1) ** 2 + (y-y1) ** 2)
            d4 = Math.sqrt((x-x3) ** 2 + (y-y3) ** 2)

            if d1 == d3 && d2 == d4 && (x2 != x || y2 != y)
              puts [x, y].join(' ')
              return
            end
          end
        end
      end
    end

    puts -1
  end
end

Yukicoder.new
0