結果
| 問題 | 
                            No.2476 Knight Game
                             | 
                    
| コンテスト | |
| ユーザー | 
                             shobonvip
                         | 
                    
| 提出日時 | 2023-09-18 21:19:41 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 644 ms / 2,000 ms | 
| コード長 | 3,435 bytes | 
| コンパイル時間 | 4,657 ms | 
| コンパイル使用メモリ | 261,724 KB | 
| 最終ジャッジ日時 | 2025-02-16 23:28:38 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 5 | 
ソースコード
#include<bits/stdc++.h>
using namespace std;
//* ATCODER
#include<atcoder/all>
using namespace atcoder;
typedef modint998244353 mint;
//*/
/* BOOST MULTIPRECISION
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
//*/
typedef long long ll;
#define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--)
template <typename T> bool chmin(T &a, const T &b) {
	if (a <= b) return false;
	a = b;
	return true;
}
template <typename T> bool chmax(T &a, const T &b) {
	if (a >= b) return false;
	a = b;
	return true;
}
template <typename T> T max(vector<T> &a){
	assert(!a.empty());
	T ret = a[0];
	for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]);
	return ret;
}
template <typename T> T min(vector<T> &a){
	assert(!a.empty());
	T ret = a[0];
	for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]);
	return ret;
}
template <typename T> T sum(vector<T> &a){
	T ret = 0;
	for (int i=0; i<(int)a.size(); i++) ret += a[i];
	return ret;
}
ll floor_sqrt(ll n){
	ll ub = 3e9 + 30;
	ll lb = 0;
	while(ub - lb > 1){
		ll t = (ub + lb) / 2;
		if (t * t <= n){
			lb = t;
		}else{
			ub = t;
		}
	}
	return lb;
}
//defmodfact
const int COMinitMAX = 992844;
mint fact[COMinitMAX+1], factinv[COMinitMAX+1];
void modfact(){
	fact[0] = 1;
	for (int i=1; i<=COMinitMAX; i++){
		fact[i] = fact[i-1] * i;
	}
	factinv[COMinitMAX] = fact[COMinitMAX].inv();
	for (int i=COMinitMAX-1; i>=0; i--){
		factinv[i] = factinv[i+1] * (i+1);
	}
}
mint cmb(int a, int b){
	if (a<b || b<0) return mint(0);
	return fact[a]*factinv[b]*factinv[a-b];
}
//--------
void naive(int h, int w){
	vector game(1<<(h*w), vector(h, vector<bool>(w)));
	vector tansaku(1<<(h*w), vector(h, vector<bool>(w)));
	vector<int> dx = {-2, -2, -1, -1, 1, 1, 2, 2};
	vector<int> dy = {-1, 1, -2, 2, -2, 2, -1, 1};
	auto dp = [&](auto self, int dat, int x, int y) -> bool {
		if (tansaku[dat][x][y]){
			return game[dat][x][y];
		}
		rep(i,0,8){
			int xx = x + dx[i];
			int yy = y + dy[i];
			if (0 <= xx && xx < h){
				if (0 <= yy && yy < w){
					if ((dat >> (xx * w + yy) & 1) == 0){
						if (!self(self, dat | (1 << (xx * w + yy)), xx, yy)){
							game[dat][x][y] = true;
							tansaku[dat][x][y] = true;
							return true;
						}
					}
				}
			}
		}
		game[dat][x][y] = false;
		tansaku[dat][x][y] = true;
		return false;
	};
	rep(i,0,h){
		rep(j,0,w){
			if (dp(dp,1<<(i*w+j),i,j)){
				cout << 1;
			}else{
				cout << 0;
			}
		}
		cout << endl;
	}
}
void solve(){
	int H, W; cin >> H >> W;
	int x, y; cin >> x >> y;
	x--; y--;
	if (H > W){
		swap(H, W);
		swap(x, y);
	}
	if (H == 1){
		cout << "Bob\n";
	}else if (H == 2){
		int lftmoval = y / 2;
		int rgtmoval = (W-y-1) / 2;
		if (lftmoval % 2 == 1 || rgtmoval % 2 == 1){
			cout << "Alice\n";
		}else{
			cout << "Bob\n";
		}
	}else if (H == 3 && W == 3){
		vector<vector<int>> ans = {
			{1, 1, 1},
			{1, 0, 1},
			{1, 1, 1}
		};
		if (ans[x][y] == 1){
			cout << "Alice\n";
		}else{
			cout << "Bob\n";
		}
	}else if (H == 3 && W == 5){
		vector<vector<int>> ans = {
			{0, 1, 1, 1, 0},
			{1, 0, 1, 0, 1},
			{0, 1, 1, 1, 0}
		};
		if (ans[x][y] == 1){
			cout << "Alice\n";
		}else{
			cout << "Bob\n";
		}
	}else if (H * W % 2 == 0){
		cout << "Alice\n";
	}else{
		if ((x + y) % 2 == 0){
			cout << "Bob\n";
		}else{
			cout << "Alice\n";
		}
	}
}
int main(){
	int t; cin >> t;
	while(t--) solve();
}
            
            
            
        
            
shobonvip