結果
問題 |
No.2278 Time Bomb Game 2
|
ユーザー |
![]() |
提出日時 | 2023-04-21 23:59:39 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,699 bytes |
コンパイル時間 | 3,774 ms |
コンパイル使用メモリ | 252,516 KB |
最終ジャッジ日時 | 2025-02-12 12:42:20 |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 68 WA * 2 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; typedef int64_t lint; #define rep(i, n) for(int i=0; i<n; i++) #define repx(i, l, n) for(int i=l; i<n; i++) #define all(v) v.begin(), v.end() #define show(x) cout << #x << ": " << x << endl; #define list(x) cout << #x << ": " << x << " "; #define pb push_back using vi = vector<lint>; using vvi = vector<vector<lint>>; template<class T> inline void vin(vector<T>& v) { rep(i, v.size()) cin >> v.at(i); } template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } template<class T> inline void drop(T x) { cout << x << endl; exit(0); } template<class T> void vout(vector<T> v) { rep(i, v.size()) { cout << v.at(i) << ' '; } cout << endl; } constexpr lint LINF = LLONG_MAX/2; lint N, K, T; string S; string solve() { lint a=0, b=0, c=0, x, y, z; repx(i, K+1, N+1) { if (i == N) a = -1; else if (S[i] == S[K]) a++; else break; } for (lint i = K-1; i >= -1; i--) { if (i == -1) b = -1; else if (S[i] == S[K]) b++; else break; } if (a > b) swap(a, b); if (a == -1) { if (b == -1) { if (S[K] == 'A') return "Bob"; else return "Alice"; } else if (T <= b) { if (S[K] == 'A') return "Bob"; else return "Alice"; } else if (b%2 != T%2) { if (S[K] == 'A') return "Alice"; else return "Bob"; } else { if (S[K] == 'A') return "Bob"; else return "Alice"; } } else if (a == 0 && b == 0) { return "Empty"; } else if (a%2 != b%2) { if (T <= a) { if (S[K] == 'A') return "Bob"; else return "Alice"; } if (S[K] == 'A') return "Alice"; else return "Bob"; } else { if (T <= a) { if (S[K] == 'A') return "Bob"; else return "Alice"; } if (b%2 != T%2) { if (S[K] == 'A') return "Alice"; else return "Bob"; } else { if (S[K] == 'A') return "Bob"; else return "Alice"; } } } int main() { cin >> N >> K >> T >> S; K--; lint a=0, b=0, c=0, x, y, z; string t = solve(); if (t != "Empty") drop(t); if (!T%2) { if (S[K] == 'A') drop("Bob"); else drop("Alice"); } T--; string t1, t2; if (K == 0) t1 = "Empty"; else { K--; t1 = solve(); K++; } if (K == N-1) t2 = "Empty"; else { K++; t2 = solve(); K--; } T++; if (t1 == "Empty" && t2 == "Empty") { if (T%2) { if (S[K] == 'A') drop("Alice"); else drop("Bob"); } else { if (S[K] == 'A') drop("Bob"); else drop("Alice"); } } else if (t1 == "Empty") { drop(t2); } else if (t2 == "Empty") { drop(t1); } else if (t1 != t2) { if (S[K] == 'A') drop("Alice"); else drop("Bob"); } else { drop(t1); } }