結果

問題 No.459 C-VS for yukicoder
ユーザー maimai
提出日時 2016-12-04 01:30:05
言語 Ruby
(3.3.0)
結果
AC  
実行時間 262 ms / 2,000 ms
コード長 1,185 bytes
コンパイル時間 152 ms
コンパイル使用メモリ 11,328 KB
実行使用メモリ 18,268 KB
最終ジャッジ日時 2023-08-27 02:41:06
合計ジャッジ時間 9,153 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
15,188 KB
testcase_01 AC 83 ms
15,140 KB
testcase_02 AC 74 ms
15,316 KB
testcase_03 AC 73 ms
15,112 KB
testcase_04 AC 74 ms
15,136 KB
testcase_05 AC 78 ms
15,240 KB
testcase_06 AC 70 ms
15,296 KB
testcase_07 AC 74 ms
15,108 KB
testcase_08 AC 76 ms
15,088 KB
testcase_09 AC 75 ms
15,028 KB
testcase_10 AC 74 ms
15,140 KB
testcase_11 AC 74 ms
15,344 KB
testcase_12 AC 75 ms
15,304 KB
testcase_13 AC 73 ms
15,088 KB
testcase_14 AC 74 ms
15,180 KB
testcase_15 AC 80 ms
15,292 KB
testcase_16 AC 79 ms
15,420 KB
testcase_17 AC 77 ms
15,232 KB
testcase_18 AC 79 ms
15,144 KB
testcase_19 AC 75 ms
15,300 KB
testcase_20 AC 73 ms
15,364 KB
testcase_21 AC 261 ms
18,268 KB
testcase_22 AC 260 ms
17,664 KB
testcase_23 AC 262 ms
17,860 KB
testcase_24 AC 143 ms
16,588 KB
testcase_25 AC 105 ms
16,168 KB
testcase_26 AC 108 ms
15,480 KB
testcase_27 AC 100 ms
15,604 KB
testcase_28 AC 100 ms
16,312 KB
testcase_29 AC 149 ms
16,028 KB
testcase_30 AC 107 ms
15,376 KB
testcase_31 AC 124 ms
16,040 KB
testcase_32 AC 83 ms
15,380 KB
testcase_33 AC 122 ms
16,208 KB
testcase_34 AC 124 ms
16,124 KB
testcase_35 AC 84 ms
15,304 KB
testcase_36 AC 127 ms
15,696 KB
testcase_37 AC 85 ms
15,208 KB
testcase_38 AC 118 ms
16,392 KB
testcase_39 AC 81 ms
15,256 KB
testcase_40 AC 112 ms
15,656 KB
testcase_41 AC 79 ms
15,436 KB
testcase_42 AC 108 ms
15,560 KB
testcase_43 AC 124 ms
16,164 KB
testcase_44 AC 88 ms
15,400 KB
testcase_45 AC 87 ms
15,364 KB
testcase_46 AC 91 ms
15,472 KB
testcase_47 AC 86 ms
15,404 KB
testcase_48 AC 127 ms
15,944 KB
testcase_49 AC 84 ms
15,484 KB
testcase_50 AC 116 ms
15,940 KB
testcase_51 AC 80 ms
15,200 KB
testcase_52 AC 97 ms
15,744 KB
testcase_53 AC 83 ms
15,336 KB
testcase_54 AC 120 ms
16,124 KB
testcase_55 AC 93 ms
15,480 KB
testcase_56 AC 111 ms
15,788 KB
testcase_57 AC 80 ms
15,292 KB
testcase_58 AC 129 ms
16,152 KB
testcase_59 AC 87 ms
15,544 KB
testcase_60 AC 103 ms
15,668 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

# AC : パックを上下逆にする

def max(a,b);a>=b ? a : b;end
def min(a,b);a<=b ? a : b;end


@height,@width,@n = gets.split.map(&:to_i)


field = Array.new(@width,0)

@height.times{
    x = 0
    gets.chomp!.chars{|c|
        field[x]+=1 if c=='#'
        x+=1
    }
}


command = Array.new(@n,0)
pack = Array.new(@n){Array.new(3,0)}
command_bucket = Array.new(@width){[]}

@n.times{|i|
    x = gets.to_i
    command[i] = x
    command_bucket[x] << i
}

cursor = 0
@width.times{|x|
    cursor = max(x,cursor)
    command_bucket[x].each{|idx|
        while (field[cursor] == 0) ; cursor += 1 ; end
        pack[idx][cursor-x] += 1
        field[cursor] -= 1
    }
}

@width.times{|x|
    command_bucket[x].each{|idx|
        3.times{|ofs|
            fil = max(0,min(3-pack[idx][ofs],field[x+ofs]))
            pack[idx][ofs] += fil
            field[x+ofs]   -= fil
        }
    }
}

pack.each{|v|
    1.upto(3){|y|
        0.upto(2){|x|
            print (y <= v[x]) ? '#' : '.'
        }
        puts ""
    }
}


puts "" # 末尾の改行はしているはずだけれども念のため

puts "" # 心配だからもう1個

puts "" # まだ不安?

puts "" # ・・・

0