牛客網-道に迷った牛Python
683 ワード
N = int(input()) #
direction = list(input()) #
temp = "N"
for i in range(N):
if(temp=="N"):
if(direction[i]=='L'):
temp='W'
else:
temp='E'
elif(temp=="E"):
if(direction[i]=='L'):
temp='N'
else:
temp='S'
elif(temp=='S'):
if(direction[i]=='L'):
temp='E'
else:
temp='W'
else:
if(direction[i]=='L'):
temp='S'
else:
temp='N'
print(temp)