結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
12,160 KB
testcase_01 AC 90 ms
12,288 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 81 ms
12,288 KB
testcase_06 AC 92 ms
14,720 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 127 ms
22,912 KB
testcase_11 AC 126 ms
22,656 KB
testcase_12 AC 141 ms
22,656 KB
testcase_13 AC 124 ms
22,784 KB
testcase_14 AC 126 ms
22,528 KB
testcase_15 AC 128 ms
22,656 KB
testcase_16 AC 129 ms
22,656 KB
testcase_17 AC 128 ms
22,912 KB
testcase_18 AC 125 ms
22,656 KB
testcase_19 AC 133 ms
22,912 KB
testcase_20 AC 124 ms
22,784 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 130 ms
22,656 KB
testcase_38 WA -
testcase_39 AC 129 ms
22,656 KB
testcase_40 WA -
testcase_41 AC 131 ms
22,784 KB
testcase_42 AC 150 ms
22,656 KB
testcase_43 AC 136 ms
22,784 KB
testcase_44 AC 142 ms
22,656 KB
testcase_45 AC 138 ms
22,784 KB
testcase_46 AC 146 ms
22,912 KB
testcase_47 AC 132 ms
22,784 KB
testcase_48 AC 128 ms
22,656 KB
testcase_49 AC 134 ms
22,784 KB
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
testcase_62 WA -
testcase_63 WA -
testcase_64 AC 141 ms
22,528 KB
testcase_65 AC 147 ms
22,656 KB
testcase_66 AC 146 ms
22,912 KB
testcase_67 AC 145 ms
22,528 KB
testcase_68 AC 125 ms
22,912 KB
testcase_69 AC 141 ms
22,656 KB
testcase_70 WA -
testcase_71 AC 85 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?
      true
    else
      if repeated
        true
      else
        res = false

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

        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