結果

問題 No.232 めぐるはめぐる (2)
ユーザー simansiman
提出日時 2016-03-26 21:14:19
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 1,521 bytes
コンパイル時間 39 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 13,184 KB
最終ジャッジ日時 2024-04-10 00:04:39
合計ジャッジ時間 3,732 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
12,928 KB
testcase_01 AC 117 ms
13,184 KB
testcase_02 AC 118 ms
12,928 KB
testcase_03 AC 117 ms
13,056 KB
testcase_04 AC 84 ms
12,160 KB
testcase_05 AC 86 ms
12,288 KB
testcase_06 AC 86 ms
12,416 KB
testcase_07 AC 84 ms
12,416 KB
testcase_08 AC 109 ms
12,928 KB
testcase_09 AC 88 ms
12,160 KB
testcase_10 AC 88 ms
12,160 KB
testcase_11 AC 87 ms
12,288 KB
testcase_12 AC 85 ms
12,160 KB
testcase_13 AC 90 ms
12,288 KB
testcase_14 AC 88 ms
12,160 KB
testcase_15 WA -
testcase_16 AC 88 ms
12,416 KB
testcase_17 AC 88 ms
12,288 KB
testcase_18 AC 86 ms
12,160 KB
testcase_19 AC 86 ms
12,160 KB
testcase_20 AC 84 ms
12,160 KB
testcase_21 AC 86 ms
12,288 KB
testcase_22 AC 85 ms
12,288 KB
testcase_23 AC 85 ms
12,160 KB
testcase_24 AC 85 ms
12,288 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:7: warning: assigned but unused variable - n
Main.rb:11: warning: assigned but unused variable - tm
Main.rb:12: warning: assigned but unused variable - tn
Syntax OK

ソースコード

diff #

class Yukicoder
  LAST_ONE = %w(x > ^ ^>)

  def initialize
    t, y, x = gets.chomp.split.map(&:to_i)
    m = [y,x].max
    n = [y,x].min

    ty = y-1
    tx = x-1
    tm = [ty,tx].max
    tn = [ty,tx].min

    answer = []

    if m > t
      puts "NO"
      return
    else
      if t == 1
        if y == 0 && x == 0
          puts "NO"
          return
        else
          puts LAST_ONE[y*2+x]
        end
      else
        if ty < 0
          if tx == 0
            answer << ['v']
            t -= 1
          elsif tx < 0
            answer << ['<v']
            t -= 1
          else
            answer << ['v>']
            answer << ['>'] * (tx-1)
            t -= tx
          end
        elsif tx < 0
          if ty == 0
            answer << ['<']
            t -= 1
          else
            answer << ['<^']
            answer << ['^'] * (ty-1)
            t -= ty
          end
        elsif ty > tx
          answer << ['^>'] * tx
          answer << ['^'] * (ty-tx)
          t -= ty
        elsif ty < tx
          answer << ['^>'] * ty
          answer << ['>'] * (tx-ty)
          t -= tx
        else
          answer << ['^>'] * ty
          t -= ty
        end

        if t.odd?
          if t > 1
            answer << ['>','<'] * ((t-1)/2)
          end

          answer << '^>'
        else
          if t > 2
            answer << ['>','<'] * ((t-1)/2)
          end

          answer << ['>','^']
        end
      end
    end

    puts "YES"
    puts answer
  end
end

Yukicoder.new
0