显示原始代码
#include <bits/stdc++.h>
using namespace std;
int ww[2][35][35][35][3][3];
int xy[4] = { 0, 1, 0, -1 };
int yy[4] = { 1, 0, -1, 0 };
int n, a1, b1, c1, d1, a2, b2, c2, d2;
void dfs(int ab, int x1, int y1, int x2, int stg, int rf) {
int y2 = n - (x1 + y1 - 2 - (n - x2));
if (ab != 0) {
y2++;
}
if (stg == 1 && abs(x1 - x2) + abs(y1 - y2) <= 1) {
ww[ab][x1][y1][x2][stg][rf] = 1;
return;
}
if (stg == 2 && abs(x1 - x2) + abs(y1 - y2) <= 1) {
ww[ab][x1][y1][x2][stg][rf] = 2;
return;
}
if (rf == 1 && (x1 == x2 || y1 == y2)) {
cout << rf << ' ' << (rf == 1) << endl;
ww[ab][x1][y1][x2][stg][rf] = 1;
return;
}
if (rf == 2 && (x1 == x2 || y1 == y2)) {
ww[ab][x1][y1][x2][stg][rf] = 2;
return;
}
if (x1 == n && y1 == n && x2 == 1 && y2 == 1) {
ww[ab][x1][y1][x2][stg][rf] = 0;
return;
}
if (ab == 0) {
int a2 = 1;
for (int i = 0; i < 2; i++) {
int tx = x1 + xy[i];
int ty = y1 + yy[i];
if (tx <= 0 || tx > n || ty <= 0 || ty > n)
continue;
int tstg = stg;
int trf = rf;
if (stg == 0) {
if (x1 == a1 && y1 == b1 && tx == c1 && ty == d1) {
tstg = 1;
}
if (x1 == c1 && y1 == d1 && tx == a1 && ty == b1) {
tstg = 1;
}
}
if (rf == 0) {
if (x1 == a2 && y1 == b2 && tx == c2 && ty == d2) {
trf = 1;
}
if (x1 == c2 && y1 == d2 && tx == a2 && ty == b2) {
trf = 1;
}
}
if (ww[1][tx][ty][x2][tstg][trf] == -1) {
dfs(1 - ab, tx, ty, x2, tstg, trf);
}
if (ww[1][tx][ty][x2][tstg][trf] == 1) {
ww[ab][x1][y1][x2][stg][rf] = 1;
return;
}
if (ww[1][tx][ty][x2][tstg][trf] != 2) {
a2 = 0;
}
}
if (a2 == 1) {
ww[ab][x1][y1][x2][stg][rf] = 2;
} else {
ww[ab][x1][y1][x2][stg][rf] = 0;
}
} else {
int a1 = 1;
for (int i = 2; i < 4; i++) {
int tx = x2 + xy[i];
int ty = y2 + yy[i];
if (tx <= 0 || tx > n || ty <= 0 || ty > n)
continue;
int tstg = stg;
int trf = rf;
if (stg == 0) {
if (x2 == a1 && y2 == b1 && tx == c1 && ty == d1) {
tstg = 2;
}
if (x2 == c1 && y2 == d1 && tx == a1 && ty == b1) {
tstg = 2;
}
}
if (rf == 0) {
if (x2 == a2 && y2 == b2 && tx == c2 && ty == d2) {
trf = 2;
}
if (x2 == c2 && y2 == d2 && tx == a2 && ty == b2) {
trf = 2;
}
}
if (ww[0][x1][y1][tx][tstg][trf] == -1) {
dfs(1 - ab, x1, y1, tx, tstg, trf);
}
if (ww[0][x1][y1][tx][tstg][trf] == 2) {
ww[ab][x1][y1][x2][stg][rf] = 2;
return;
}
if (ww[0][x1][y1][tx][tstg][trf] != 1) {
a1 = 0;
}
}
if (a1 == 1) {
ww[ab][x1][y1][x2][stg][rf] = 1;
} else {
ww[ab][x1][y1][x2][stg][rf] = 0;
}
}
return;
}
int main() {
int t;
cin >> t;
while (t--) {
memset(ww, -1, sizeof(ww));
cin >> n >> a1 >> b1 >> c1 >> d1 >> a2 >> b2 >> c2 >> d2;
dfs(0, 1, 1, n, 0, 0);
if (ww[0][1][1][n][0][0] == 0) {
cout << "0\n";
} else if (ww[0][1][1][n][0][0] == 1) {
cout << "Alice\n";
} else {
cout << "Bob\n";
}
}
return 0;
}