题解 | #二维数组操作#
二维数组操作
https://www.nowcoder.com/practice/2f8c17bec47e416897ce4b9aa560b7f4
while True:
try:
size = list([int(i) for i in input().split()])
swap = list([int(i) for i in input().split()])
row = list([int(i) for i in input().split()])
col = list([int(i) for i in input().split()])
coor = list([int(i) for i in input().split()])
if size[0]>9 or size[1]>9: # can't initialize
print(-1)
print(-1)
print(-1)
print(-1)
print(-1)
else:
print(0)
if swap[0]+1 <= size[0] and swap[2]+1<=size[0] and swap[1]+1<=size[1] and swap[3]+1 <=size[1]: #if swap valids
print(0)
else:
print(-1)
if row[0]>=0 and row[0]<=size[0] -1 and size[0] < 9:
print(0)
#size[0] += 1
else:
print(-1)
if col[0]>=0 and col[0]<=size[1]-1 and size[1] < 9:
print(0)
#size[1] += 1
else:
print(-1)
if coor[0]>=0 and coor[0]+1<= size[0] and coor[1]>=0 and coor[1]+1<=size[1]:
print(0)
else:
print(-1)
except:
break
查看6道真题和解析