为什么不对呢?
出现的是RE错误
代码:
x1,y1=map(int,input().split())
x2,y2=map(int,input().split())
T=int(input())
li=[0 for _ in range(T)]
for i in range(T):
li[i]=input()
dir={'N':(0,1),'S':(0,-1),'W':(-1,0),'E':(1,0)}
step=0
for i in range(T):
if x1==x2 and y1==y2:
print(step)
break
else:
if (x1-x2)**2+(y1-y2)**2 > (dir[li[i]][0]+x1-x2)**2+(dir[li[i]][1]+y1-y2)**2:
x1+=dir[li[i]][0]
y1+=dir[li[i]][1]
step+=1
if i==T-1:
if x1!=x2 and y1!=y2:
print(-1)
else:
print(step)