結果

問題 No.232 めぐるはめぐる (2)
ユーザー simansiman
提出日時 2016-03-26 21:15:20
言語 Ruby
(3.3.0)
結果
AC  
実行時間 107 ms / 1,000 ms
コード長 1,559 bytes
コンパイル時間 263 ms
コンパイル使用メモリ 11,564 KB
実行使用メモリ 16,256 KB
最終ジャッジ日時 2023-10-12 13:45:12
合計ジャッジ時間 3,616 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 107 ms
16,216 KB
testcase_01 AC 107 ms
16,084 KB
testcase_02 AC 107 ms
16,056 KB
testcase_03 AC 107 ms
16,256 KB
testcase_04 AC 79 ms
15,116 KB
testcase_05 AC 78 ms
15,264 KB
testcase_06 AC 77 ms
15,236 KB
testcase_07 AC 79 ms
15,328 KB
testcase_08 AC 97 ms
15,708 KB
testcase_09 AC 79 ms
15,176 KB
testcase_10 AC 78 ms
15,156 KB
testcase_11 AC 79 ms
15,148 KB
testcase_12 AC 78 ms
15,340 KB
testcase_13 AC 78 ms
15,072 KB
testcase_14 AC 78 ms
15,136 KB
testcase_15 AC 78 ms
15,040 KB
testcase_16 AC 77 ms
15,308 KB
testcase_17 AC 78 ms
15,256 KB
testcase_18 AC 80 ms
15,236 KB
testcase_19 AC 78 ms
15,104 KB
testcase_20 AC 78 ms
15,328 KB
testcase_21 AC 78 ms
15,236 KB
testcase_22 AC 78 ms
15,288 KB
testcase_23 AC 77 ms
15,076 KB
testcase_24 AC 77 ms
15,188 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 "YES"
          puts LAST_ONE[y*2+x]
          return
        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