結果

問題 No.459 C-VS for yukicoder
ユーザー miraxialmiraxial
提出日時 2016-12-10 00:58:00
言語 Ruby
(3.3.0)
結果
AC  
実行時間 461 ms / 2,000 ms
コード長 777 bytes
コンパイル時間 47 ms
コンパイル使用メモリ 11,244 KB
実行使用メモリ 21,156 KB
最終ジャッジ日時 2023-08-27 06:43:57
合計ジャッジ時間 11,586 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
15,112 KB
testcase_01 AC 81 ms
15,260 KB
testcase_02 AC 83 ms
15,188 KB
testcase_03 AC 82 ms
15,132 KB
testcase_04 AC 83 ms
15,156 KB
testcase_05 AC 82 ms
15,128 KB
testcase_06 AC 84 ms
15,076 KB
testcase_07 AC 83 ms
15,140 KB
testcase_08 AC 83 ms
15,100 KB
testcase_09 AC 83 ms
15,204 KB
testcase_10 AC 84 ms
15,008 KB
testcase_11 AC 84 ms
15,152 KB
testcase_12 AC 83 ms
15,056 KB
testcase_13 AC 83 ms
15,040 KB
testcase_14 AC 84 ms
15,128 KB
testcase_15 AC 92 ms
15,156 KB
testcase_16 AC 90 ms
15,144 KB
testcase_17 AC 85 ms
15,296 KB
testcase_18 AC 86 ms
15,060 KB
testcase_19 AC 85 ms
15,084 KB
testcase_20 AC 86 ms
15,060 KB
testcase_21 AC 461 ms
20,780 KB
testcase_22 AC 398 ms
21,156 KB
testcase_23 AC 455 ms
20,288 KB
testcase_24 AC 200 ms
16,856 KB
testcase_25 AC 130 ms
15,740 KB
testcase_26 AC 135 ms
16,016 KB
testcase_27 AC 131 ms
15,488 KB
testcase_28 AC 124 ms
15,744 KB
testcase_29 AC 199 ms
17,172 KB
testcase_30 AC 132 ms
16,056 KB
testcase_31 AC 146 ms
16,040 KB
testcase_32 AC 89 ms
15,324 KB
testcase_33 AC 152 ms
16,152 KB
testcase_34 AC 171 ms
16,388 KB
testcase_35 AC 94 ms
15,456 KB
testcase_36 AC 175 ms
16,328 KB
testcase_37 AC 93 ms
15,176 KB
testcase_38 AC 154 ms
15,968 KB
testcase_39 AC 95 ms
15,196 KB
testcase_40 AC 142 ms
15,852 KB
testcase_41 AC 88 ms
15,368 KB
testcase_42 AC 138 ms
15,844 KB
testcase_43 AC 162 ms
16,428 KB
testcase_44 AC 101 ms
15,340 KB
testcase_45 AC 99 ms
15,264 KB
testcase_46 AC 100 ms
15,044 KB
testcase_47 AC 92 ms
15,420 KB
testcase_48 AC 164 ms
16,220 KB
testcase_49 AC 92 ms
15,244 KB
testcase_50 AC 150 ms
15,876 KB
testcase_51 AC 92 ms
15,336 KB
testcase_52 AC 117 ms
15,588 KB
testcase_53 AC 96 ms
15,392 KB
testcase_54 AC 155 ms
16,016 KB
testcase_55 AC 109 ms
15,412 KB
testcase_56 AC 141 ms
15,888 KB
testcase_57 AC 92 ms
15,404 KB
testcase_58 AC 171 ms
16,156 KB
testcase_59 AC 102 ms
15,272 KB
testcase_60 AC 120 ms
15,616 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

h,w,n=gets.split.map &:to_i
a=[]
c=[0]*w
h.times do |i|
  a<< g=gets.chomp
  w.times do |i|
    c[i]+=1 if g[i]==?#
  end
end
d=[0]*w
v=*$<.map(&:to_i)
v=v[0..n-1]
v.each do |e|
  d[e]+=1
  d[e+1]+=1
  d[e+2]+=1
end
n.times do |i|
  v[i]=[v[i],i]
end
w=v.sort
f=[]
w.each do |e|
  g=[]
  3.times do |i|
    t=e[0]+i
    d[t]-=1
    if d[t]==0
      g<< c[t]
    else
      if d[t]*3<c[t]
        g<< c[t]-d[t]*3
        c[t]=d[t]*3
      else
        g<< 0
      end
    end
  end
  if g==[0,0,0]
    3.times do |i|
      t=e[0]+i
      if c[t]!=0
        g[i]+=1
        c[t]-=1
        break
      end
    end
  end
  f<< g+[e[1]]
end
f.sort!{|a,b|a[3]<=>b[3]}
f.each do |e|
  3.times do |i|
    s=""
    3.times do |j|
      s+=e[j]>=3-i ? ?#:?.
    end
    puts s
  end
end
0