4wa5ac求助
查看原帖
4wa5ac求助
585146
NKJJ楼主2022/9/26 15:53
arr=[]
edge=[]
ans=0

fsub=[]
csub=[]

def move(a,c):
    if c[2]==0:
        if a[c[0]-1][c[1]]=='*':
            c[2]=1
        else:
            c[0]-=1
    elif c[2]==1:
        if a[c[0]][c[1]+1]=='*':
            c[2]=2
        else:
            c[1]+=1
    elif c[2]==2:
        if a[c[0]+1][c[1]]=='*':
            c[2]=3
        else:
            c[0]+=1
    elif c[2]==3:
        if a[c[0]][c[1]-1]=='*':
            c[2]=0
        else:
            c[1]-=1

def equal(c,f):
    if (c[0]==f[0]) and (c[1]==f[1]):
        return True
    else:
        return False

for i in range(0,12):
    edge.append('*')


for i in range(0,10):
    tmp=input()
    k=list(tmp)
    k.insert(0, '*')
    k.append('*')
    arr.append(k)

arr.insert(0,edge)
arr.append(edge)


for i in range(0,12):
    for j in range(0,12):
        if arr[i][j]=='F':
            fsub.append(i)
            fsub.append(j)
        if arr[i][j]=='C':
            csub.append(i)
            csub.append(j)

fsub.append(0)
csub.append(0)

while not equal(fsub,csub):
    move(arr,csub)
    move(arr,fsub)
    ans+=1
    if ans>=100000:
        print(0)
        exit(0)

print(ans)

下载了第一个数据点:

..... ........* *......... .......... ........ *....** F........ ..... .C....... ........

答案是58,我运行的结果也是58,但是这个数据点显示wa了,求问为什么啊

2022/9/26 15:53
加载中...