题解 | 坐标移动
import sys def func(cmd,x,y): try: if cmd[0] not in ('A','D','W','S'): return x,y if not cmd[1:].isdigit(): return x,y steps = int(cmd[1:]) if steps < 1 or steps > 99: return x,y if cmd[0] == 'A': x -= steps if cmd[0] == 'D': x += steps if cmd[0] == 'W': y += steps if cmd[0] == 'S': y -= steps return x,y except: return x,y for line in sys.stdin: x,y = 0, 0 s = line.strip() a = line.split(';') for cmd in a: x,y = func(cmd, x, y) print(f'{x},{y}')