結果

問題 No.2278 Time Bomb Game 2
ユーザー simansiman
提出日時 2023-04-24 13:02:00
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 1,268 bytes
コンパイル時間 330 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 22,912 KB
最終ジャッジ日時 2024-04-26 02:39:01
合計ジャッジ時間 13,141 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
12,288 KB
testcase_01 AC 83 ms
12,288 KB
testcase_02 AC 83 ms
12,416 KB
testcase_03 AC 83 ms
12,288 KB
testcase_04 AC 85 ms
12,416 KB
testcase_05 AC 81 ms
12,160 KB
testcase_06 AC 94 ms
14,592 KB
testcase_07 AC 107 ms
19,328 KB
testcase_08 AC 111 ms
17,152 KB
testcase_09 AC 121 ms
22,016 KB
testcase_10 AC 129 ms
22,784 KB
testcase_11 AC 129 ms
22,656 KB
testcase_12 AC 146 ms
22,784 KB
testcase_13 AC 129 ms
22,656 KB
testcase_14 AC 130 ms
22,784 KB
testcase_15 AC 135 ms
22,656 KB
testcase_16 AC 130 ms
22,656 KB
testcase_17 AC 131 ms
22,656 KB
testcase_18 AC 129 ms
22,784 KB
testcase_19 AC 135 ms
22,784 KB
testcase_20 AC 131 ms
22,656 KB
testcase_21 AC 130 ms
22,912 KB
testcase_22 AC 127 ms
22,784 KB
testcase_23 AC 128 ms
22,784 KB
testcase_24 AC 128 ms
22,784 KB
testcase_25 AC 129 ms
22,656 KB
testcase_26 AC 129 ms
22,784 KB
testcase_27 AC 125 ms
22,656 KB
testcase_28 AC 123 ms
22,912 KB
testcase_29 AC 129 ms
22,784 KB
testcase_30 AC 128 ms
22,656 KB
testcase_31 AC 123 ms
22,912 KB
testcase_32 AC 122 ms
22,656 KB
testcase_33 AC 122 ms
22,912 KB
testcase_34 AC 128 ms
22,784 KB
testcase_35 AC 127 ms
22,784 KB
testcase_36 AC 126 ms
22,784 KB
testcase_37 AC 129 ms
22,912 KB
testcase_38 WA -
testcase_39 AC 131 ms
22,656 KB
testcase_40 AC 129 ms
22,784 KB
testcase_41 AC 134 ms
22,528 KB
testcase_42 AC 147 ms
22,912 KB
testcase_43 AC 137 ms
22,784 KB
testcase_44 AC 145 ms
22,784 KB
testcase_45 AC 143 ms
22,656 KB
testcase_46 AC 145 ms
22,912 KB
testcase_47 AC 132 ms
22,784 KB
testcase_48 AC 124 ms
22,912 KB
testcase_49 AC 130 ms
22,784 KB
testcase_50 AC 125 ms
22,784 KB
testcase_51 AC 122 ms
22,656 KB
testcase_52 AC 123 ms
22,656 KB
testcase_53 AC 125 ms
22,656 KB
testcase_54 AC 127 ms
22,784 KB
testcase_55 AC 129 ms
22,656 KB
testcase_56 WA -
testcase_57 AC 128 ms
22,784 KB
testcase_58 AC 143 ms
22,656 KB
testcase_59 AC 129 ms
22,912 KB
testcase_60 AC 127 ms
22,784 KB
testcase_61 AC 127 ms
22,784 KB
testcase_62 AC 129 ms
22,656 KB
testcase_63 AC 127 ms
22,784 KB
testcase_64 AC 138 ms
22,784 KB
testcase_65 AC 146 ms
22,784 KB
testcase_66 AC 147 ms
22,912 KB
testcase_67 AC 144 ms
22,656 KB
testcase_68 AC 124 ms
22,656 KB
testcase_69 AC 137 ms
22,912 KB
testcase_70 AC 123 ms
22,912 KB
testcase_71 AC 80 ms
12,288 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, K, T = gets.split.map(&:to_i)
C = gets.chomp.chars

def f(k, t, repeated = false)
  ch = C[k]
  has_same_tile = false

  if k > 0 && C[k - 1] == ch
    has_same_tile = true
  end

  if k + 1 < N && C[k - 1] == ch
    has_same_tile = true
  end

  if has_same_tile
    res = false

    if C[k - 1] == ch
      cur = k
      remain = t

      while cur > 0 && C[cur - 1] == C[cur]
        cur -= 1
        remain -= 1
      end

      if remain > 0 && cur > 0 && C[cur - 1] != C[cur]
        res |= remain.odd?
      end
    end

    if C[k + 1] == ch
      cur = k
      remain = t

      while cur + 1 < N && C[cur] == C[cur + 1]
        cur += 1
        remain -= 1
      end

      if remain > 0 && cur + 1 < N && C[cur] != C[cur + 1]
        res |= remain.odd?
      end
    end

    res
  else
    if t.even?
      false
    else
      if repeated
        false
      else
        res = false

        if t >= 2
          res |= !f(k - 1, t - 1, true) if k - 1 > 0
          res |= !f(k + 1, t - 1, true) if k + 1 < N
        else
          res = true
        end

        res
      end
    end
  end
end

res = f(K - 1, T)

if C[K - 1] == 'A'
  if res
    puts 'Alice'
  else
    puts 'Bob'
  end
else
  if res
    puts 'Bob'
  else
    puts 'Alice'
  end
end
0