結果

問題 No.2278 Time Bomb Game 2
ユーザー 👑 emthrmemthrm
提出日時 2023-04-21 21:49:45
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,063 bytes
コンパイル時間 3,527 ms
コンパイル使用メモリ 276,512 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 07:57:57
合計ジャッジ時間 4,945 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 WA -
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 WA -
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 WA -
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 WA -
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 WA -
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 WA -
testcase_21 AC 2 ms
5,376 KB
testcase_22 WA -
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 2 ms
5,376 KB
testcase_36 AC 2 ms
5,376 KB
testcase_37 AC 2 ms
5,376 KB
testcase_38 AC 2 ms
5,376 KB
testcase_39 AC 2 ms
5,376 KB
testcase_40 WA -
testcase_41 AC 2 ms
5,376 KB
testcase_42 WA -
testcase_43 AC 2 ms
5,376 KB
testcase_44 AC 2 ms
5,376 KB
testcase_45 WA -
testcase_46 WA -
testcase_47 AC 2 ms
5,376 KB
testcase_48 AC 2 ms
5,376 KB
testcase_49 AC 2 ms
5,376 KB
testcase_50 AC 2 ms
5,376 KB
testcase_51 WA -
testcase_52 AC 2 ms
5,376 KB
testcase_53 AC 2 ms
5,376 KB
testcase_54 AC 2 ms
5,376 KB
testcase_55 AC 2 ms
5,376 KB
testcase_56 AC 2 ms
5,376 KB
testcase_57 AC 2 ms
5,376 KB
testcase_58 WA -
testcase_59 AC 2 ms
5,376 KB
testcase_60 WA -
testcase_61 WA -
testcase_62 AC 2 ms
5,376 KB
testcase_63 AC 2 ms
5,376 KB
testcase_64 WA -
testcase_65 WA -
testcase_66 WA -
testcase_67 AC 1 ms
5,376 KB
testcase_68 AC 2 ms
5,376 KB
testcase_69 AC 2 ms
5,376 KB
testcase_70 AC 2 ms
5,376 KB
testcase_71 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr double EPS = 1e-8;
constexpr int MOD = 998244353;
// constexpr int MOD = 1000000007;
constexpr int DY4[]{1, 0, -1, 0}, DX4[]{0, -1, 0, 1};
constexpr int DY8[]{1, 1, 0, -1, -1, -1, 0, 1};
constexpr int DX8[]{0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U>
inline bool chmax(T& a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U>
inline bool chmin(T& a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);
  }
} iosetup;

bool can_win(const int k, const int t, const string& c) {
  const int n = c.length();
  int l = k - 1, r = k + 1;
  while (l >= 0 && c[l] == c[k]) --l;
  while (r < n && c[r] == c[k]) ++r;
  return (l >= 0 && k - l <= t && (k - l) % 2 == 0) ||
         (r < n && r - k <= t && (r - k) % 2 == 0);
}

int main() {
  int n, k, t; string c; cin >> n >> k >> t >> c; --k;
  if (t % 2 == 1) {
    if (c[k] == 'A') {
      bool ans = false;
      for (const int p : vector<int>{k - 1, k + 1}) {
        if (0 <= p && p < n) {
          if (c[p] == 'A') {
            ans |= can_win(p, t - 1, c);
          } else if (c[p] == 'B') {
            ans |= !can_win(p, t - 1, c);
          }
        }
      }
      cout << (ans ? "Alice\n" : "Bob\n");
    } else if (c[k] == 'B') {
      bool ans = false;
      for (const int p : vector<int>{k - 1, k + 1}) {
        if (0 <= p && p < n) {
          if (c[p] == 'A') {
            ans |= !can_win(p, t - 1, c);
          } else if (c[p] == 'B') {
            ans |= can_win(p, t - 1, c);
          }
        }
      }
      cout << (ans ? "Bob\n" : "Alice\n");
    }
  } else {
    cout << (can_win(k, t, c) ? "Alice\n" : "Bob\n");
  }
  return 0;
}
0