結果
問題 | No.2103 ±1s Game |
ユーザー |
👑 ![]() |
提出日時 | 2022-10-21 21:29:59 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 29 ms / 1,000 ms |
コード長 | 1,218 bytes |
コンパイル時間 | 2,131 ms |
コンパイル使用メモリ | 110,280 KB |
最終ジャッジ日時 | 2025-02-08 09:50:21 |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
ソースコード
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <utility> #include <atcoder/modint> using namespace std; using i32 = int32_t; using u32 = uint32_t; using i64 = int64_t; using u64 = uint64_t; #define rep(i,n) for(int i=0; i<(int)(n); i++) const i64 INF = 1001001001001001001; using Modint = atcoder::static_modint<998244353>; bool solve2(i64 x, i64 y, i64 k, i64 p){ // (x+y-k) % 2 == 0 if(x-y >= k) return p == -1; if(y-x >= k){ if(k % 2 == 0) return p == -1; return p == 1; } return false; } bool solve(i64 x, i64 y, i64 k, i64 p){ if((x+y-k)%2 == 1){ bool q1 = !solve2(x-1, y, k, p); bool q2 = !solve2(x, y-1, k, p); return q1 || q2; } // (x+y-k) % 2 == 0 if(x-y >= k) return p == 1; if(y-x >= k){ if(k % 2 == 0) return p == 1; return p == -1; } return false; } int main(){ i64 X, Y, K, P; cin >> X >> Y >> K >> P; bool ans = solve(X,Y,K,P); cout << (ans ? "Alice" : "Bob") << '\n'; return 0; } struct ios_do_not_sync{ ios_do_not_sync(){ std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } } ios_do_not_sync_instance;