結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 114 ms
12,928 KB
testcase_02 AC 114 ms
12,928 KB
testcase_03 AC 108 ms
13,056 KB
testcase_04 AC 79 ms
12,160 KB
testcase_05 AC 81 ms
12,160 KB
testcase_06 RE -
testcase_07 AC 81 ms
12,416 KB
testcase_08 AC 101 ms
12,672 KB
testcase_09 AC 82 ms
12,288 KB
testcase_10 AC 82 ms
12,160 KB
testcase_11 AC 83 ms
12,416 KB
testcase_12 AC 81 ms
12,416 KB
testcase_13 RE -
testcase_14 AC 81 ms
12,160 KB
testcase_15 WA -
testcase_16 AC 81 ms
12,160 KB
testcase_17 AC 82 ms
12,160 KB
testcase_18 AC 83 ms
12,416 KB
testcase_19 AC 81 ms
12,160 KB
testcase_20 AC 81 ms
12,288 KB
testcase_21 AC 82 ms
12,160 KB
testcase_22 AC 80 ms
12,288 KB
testcase_23 AC 81 ms
12,160 KB
testcase_24 AC 80 ms
12,160 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
          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