結果

問題 No.457 (^^*)
ユーザー TANIGUCHI KousukeTANIGUCHI Kousuke
提出日時 2020-01-25 01:56:06
言語 Ruby
(3.3.0)
結果
AC  
実行時間 103 ms / 2,000 ms
コード長 562 bytes
コンパイル時間 414 ms
コンパイル使用メモリ 11,312 KB
実行使用メモリ 15,844 KB
最終ジャッジ日時 2023-10-12 04:27:52
合計ジャッジ時間 3,105 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
15,192 KB
testcase_01 AC 79 ms
15,040 KB
testcase_02 AC 79 ms
15,096 KB
testcase_03 AC 82 ms
15,084 KB
testcase_04 AC 82 ms
15,364 KB
testcase_05 AC 83 ms
15,164 KB
testcase_06 AC 81 ms
15,120 KB
testcase_07 AC 84 ms
15,084 KB
testcase_08 AC 85 ms
15,092 KB
testcase_09 AC 84 ms
15,096 KB
testcase_10 AC 88 ms
15,444 KB
testcase_11 AC 95 ms
15,540 KB
testcase_12 AC 98 ms
15,844 KB
testcase_13 AC 103 ms
15,792 KB
testcase_14 AC 90 ms
15,684 KB
testcase_15 AC 98 ms
15,684 KB
testcase_16 AC 103 ms
15,616 KB
testcase_17 AC 91 ms
15,452 KB
testcase_18 AC 81 ms
15,008 KB
testcase_19 AC 79 ms
15,144 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

S = gets.chomp

C = '(*^)'
C_MIN = Array.new(4){ Array.new(S.size + 2, S.size) }
RB = Array.new(S.size + 2, 0)

(1 .. S.size).each do |d|
  i = S.size - d
  j_ = C.index(S[i])
  4.times{|j| C_MIN[j][i] = (j == j_ ? i : C_MIN[j][i + 1]) }
  RB[i] = (j_ == 3 ? RB[i + 1] + 1 : RB[i + 1])
end

def count_face(dir)
  mid = dir.chars.map{|c| C.index(c) }
  face = 0
  l = 0
  while l < S.size
    l = C_MIN[0][l] + 1
    face += RB[mid.inject(l){|i,j| C_MIN[j][i] + 1 }]
  end
  face
end
rface = count_face('*^^')
lface = count_face('^^*')

puts "#{lface} #{rface}"

0