From 9c08ef199db5a709f07764037a7834c7a2e7e771 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=95=EC=A4=80=EC=9A=A9?= Date: Sun, 26 Jan 2025 15:56:01 +0900 Subject: [PATCH] wnsmir-15 --- ...01\355\225\230\354\242\214\354\232\260.py" | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 "wnsmir/\352\265\254\355\230\204/\354\203\201\355\225\230\354\242\214\354\232\260.py" diff --git "a/wnsmir/\352\265\254\355\230\204/\354\203\201\355\225\230\354\242\214\354\232\260.py" "b/wnsmir/\352\265\254\355\230\204/\354\203\201\355\225\230\354\242\214\354\232\260.py" new file mode 100644 index 0000000..720fbea --- /dev/null +++ "b/wnsmir/\352\265\254\355\230\204/\354\203\201\355\225\230\354\242\214\354\232\260.py" @@ -0,0 +1,21 @@ +N = int(input()) +orders = input().split() +dx = [0, 0, -1, 1] +dy = [-1, 1, 0, 0] +directions = ["U", "D", "L", "R"] + +x, y = 1, 1 + +for order in orders: + for i in range(4): + if order == directions[i]: + nx = x + dx[i] + ny = y + dy[i] + + if nx < 1 or ny < 1 or nx > N or ny > N: + continue + else: + x = nx + y = ny + +print(x, y) \ No newline at end of file