20
2 2 1 2 2 1 1 1 2
2 1 1 2 1 1 1 1 2
2 2 1 2 2 2 1 2 2
2 1 2 2 2 2 1 2 2
2 1 1 1 2 1 1 1 2
2 1 1 2
<262 bytes omitted>
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#101572 | #1437. [L3-2] Ice World | Time Limit Exceeded | 0 | 10304 ms | 149208 K | Python 3 / 4.8 K | Rhodoks | 2024-03-13 16:46:19 |
N = 31
n = 0
a1 = 0
a2 = 0
b1 = 0
b2 = 0
c1 = 0
c2 = 0
d1 = 0
d2 = 0
dp = [[[[[[0 for _ in range(2)] for _ in range(4)] for _ in range(4)] for _ in range(N)] for _ in range(N)] for _ in range(2*N)]
vis = [[[[[[0 for _ in range(2)] for _ in range(4)] for _ in range(4)] for _ in range(N)] for _ in range(N)] for _ in range(2*N)]
dx = [0,1,0,-1]
dy = [1,0,-1,0]
def cp1(x1,y1,xx,yy):
global a1,b1,c1,d1
if x1==a1 and y1==b1 and xx==c1 and yy==d1:
return True
if x1==c1 and y1==d1 and xx==a1 and yy==b1:
return True
return False
def cp2(x1,y1,xx,yy):
global a2,b2,c2,d2
if x1==a2 and y1==b2 and xx==c2 and yy==d2:
return True
if x1==c2 and y1==d2 and xx==a2 and yy==b2:
return True
return False
def chk(x1,y1,x2,y2,t1,t2):
d = abs(x1-x2)+abs(y1-y2)
if d<=1:
if t1&1:
return 1
if t2&1:
return -1
if x1==x2 or y1==y2:
if t1&2:
return 1
if t2&2:
return -1
return 0
def f(X,y1,y2,t1,t2,T):
global vis,dp,dx,dy,n
x1 = X+2-y1
x2 = 2*n-X-y2+T
# print(x1,y1,x2,y2)
if vis[X][y1][y2][t1][t2][T]:
return dp[X][y1][y2][t1][t2][T]
# print(x1,y1,x2,y2,t1,t2)
vis[X][y1][y2][t1][t2][T]=True
if x1==n and y1==n and x2==1 and y2==1:
dp[X][y1][y2][t1][t2][T]=0
return 0
t=1-T
if t==1:
ansk=-1
for k in range(0,2):
xx=x1+dx[k]
yy=y1+dy[k]
if xx<1 or xx>n or yy<1 or yy>n:
continue
if ((t2&1)!=1) and cp1(x1,y1,xx,yy):
d=chk(xx,yy,x2,y2,t1+1,t2)
if d==1:
dp[X][y1][y2][t1][t2][T]=1
return 1
elif d==-1:
continue
d=f(X+1,yy,y2,t1+1,t2,1)
if(d==1):
dp[X][y1][y2][t1][t2][T]=1
return 1
ansk=max(ansk,d)
if ((t2&2)!=2) and cp2(x1,y1,xx,yy):
d=chk(xx,yy,x2,y2,t1+2,t2)
if d==1:
dp[X][y1][y2][t1][t2][T]=1
return 1
elif d==-1:
continue
d=f(X+1,yy,y2,t1+2,t2,1)
if(d==1):
dp[X][y1][y2][t1][t2][T]=1
return 1
ansk=max(ansk,d)
d=chk(xx,yy,x2,y2,t1,t2)
if d==1:
dp[X][y1][y2][t1][t2][T]=1
return 1
elif d==-1:
continue
d=f(X+1,yy,y2,t1,t2,1)
if(d==1):
dp[X][y1][y2][t1][t2][T]=1
return 1
ansk=max(ansk,d)
dp[X][y1][y2][t1][t2][T]=ansk
return ansk
else:
ansk=1
for k in range(2,4):
xx=x2+dx[k]
yy=y2+dy[k]
if(xx<1 or xx>n or yy<1 or yy>n):
continue
if((t1&1)!=1) and (cp1(x2,y2,xx,yy)):
d=chk(x1,y1,xx,yy,t1,t2+1)
if(d==-1):
dp[X][y1][y2][t1][t2][T]=-1
return -1
elif(d==1):
continue
d=f(X,y1,yy,t1,t2+1,0)
if(d==-1):
dp[X][y1][y2][t1][t2][T]=-1
return -1
ansk=min(ansk,d)
if((t1&2)!=2) and (cp2(x2,y2,xx,yy)):
d=chk(x1,y1,xx,yy,t1,t2+2)
if(d==-1):
dp[X][y1][y2][t1][t2][T]=-1
return -1
elif(d==1):
continue
d=f(X,y1,yy,t1,t2+2,0)
if(d==-1):
dp[X][y1][y2][t1][t2][T]=-1
return -1
ansk=min(ansk,d)
d=chk(x1,y1,xx,yy,t1,t2)
if d==-1:
dp[X][y1][y2][t1][t2][T]=-1
return -1
elif d==1:
continue
d=f(X,y1,yy,t1,t2,0)
if(d==-1):
dp[X][y1][y2][t1][t2][T]=-1
return -1
ansk=min(ansk,d)
dp[X][y1][y2][t1][t2][T]=ansk
return ansk
def main():
tests = int(input())
for i in range(tests):
global n,a1,a2,b1,b2,c1,c2,d1,d2,vis
str = input().split(" ")
n=int(str[0])
a1=int(str[1])
b1=int(str[2])
c1=int(str[3])
d1=int(str[4])
a2=int(str[5])
b2=int(str[6])
c2=int(str[7])
d2=int(str[8])
N=n+1
d = f(0,1,n,0,0,0)
if d==1:
print("Alice")
elif d==-1:
print("Bob")
else:
print("0")
main()
20
2 2 1 2 2 1 1 1 2
2 1 1 2 1 1 1 1 2
2 2 1 2 2 2 1 2 2
2 1 2 2 2 2 1 2 2
2 1 1 1 2 1 1 1 2
2 1 1 2
<262 bytes omitted>
20
5 5 3 5 4 2 4 3 4
5 2 3 3 3 2 2 2 3
4 2 1 2 2 3 4 4 4
6 1 2 1 3 1 2 2 2
6 5 1 5 2 6 5 6 6
4 4 3 4
<262 bytes omitted>
20
3 1 3 2 3 1 2 1 3
6 6 2 6 3 5 4 5 5
4 4 2 4 3 1 2 2 2
3 1 3 2 3 2 2 3 2
3 2 2 3 2 1 3 2 3
5 4 1 5
<262 bytes omitted>
20
5 4 3 4 4 2 3 2 4
4 3 4 4 4 3 4 4 4
3 2 1 2 2 2 3 3 3
4 1 4 2 4 1 1 1 2
4 1 1 1 2 4 1 4 2
6 3 4 3
<262 bytes omitted>
20
3 2 2 3 2 1 1 1 2
6 5 5 5 6 1 5 2 5
3 2 3 3 3 2 1 3 1
5 1 3 1 4 2 3 2 4
5 2 3 3 3 2 5 3 5
4 1 2 1
<262 bytes omitted>
20
9 4 2 4 3 4 7 5 7
9 3 7 4 7 4 4 5 4
10 2 9 3 9 9 8 10 8
9 4 1 5 1 7 7 7 8
9 8 7 9 7 4 1 5 1
10 7
<276 bytes omitted>
20
10 4 2 5 2 8 1 8 2
9 9 3 9 4 6 3 7 3
10 4 6 5 6 3 4 3 5
9 7 9 8 9 1 6 2 6
9 7 7 7 8 6 8 7 8
9 4 3
<274 bytes omitted>
20
12 11 6 11 7 4 7 5 7
10 3 7 4 7 7 1 8 1
18 9 16 10 16 12 10 12 11
22 12 13 13 13 4 9 5 9
5 4 2 4
<344 bytes omitted>
20
5 3 2 4 2 4 2 4 3
6 5 3 5 4 3 2 4 2
5 4 5 5 5 4 1 5 1
8 5 6 5 7 7 5 7 6
21 3 4 3 5 18 21 19 21
15
<339 bytes omitted>