No.1133 Kimwipe Eater
Problem Statement
null-kun loves Kimwipes more than any other food.
Currently, one Kimwipe is placed on each lattice point inside the square from $(0, 0)$ to $(n, n)$ on the coordinate plane.
On the coordinate plane, $x$ is horizontal and $y$ is vertical. $(0,0)$ is at the bottom left, and the rightward and upward directions are positive.
null-kun is initially at $(0,0)$.
null-kun will now move $m$ times. If there is a Kimwipe at the destination of a move, he eats it. The Kimwipe at $(0,0)$ is considered to have already been eaten.
Output whether a Kimwipe exists on each lattice point after the $m$ moves.
Constraints
- $1 \le n \le 200$
- $1 \le m \le 10^6$
- $|s| = m$ (here, $|s|$ denotes the length of $s$)
- $n,m$ are all integers
- $s$ contains only the characters
U,R,L,D
Input
$n \ m$ $s$
The moves never go outside the square from $(0,0)$ to $(n,n)$ in terms of both the $x,y$ coordinates.
The moves are given by $s$. Letting $(a,b)$ be the coordinates before a move, U represents an upward move to $(a, b + 1)$, R a rightward move to $(a + 1,b)$, L a leftward move to $(a - 1, b)$, and D a downward move to $(a, b - 1)$.
Output
Print an output of size $(n + 1) \times (n + 1)$.
For the lattice points, print 1 if there is a Kimwipe at that point and 0 if there is not, separated by spaces.
Do not include a space at the end of a line. Print a newline at the end.
Sample
Sample 1
Input
2 8 RRULLURR
Output
0 0 0 0 0 0 0 0 0
He ate all of them.
Sample 2
Input
1 2 RL
Output
1 1 0 0
Note that the bottom left is $(0, 0)$ and the top right is $(n, n)$.
Source
Beginners After Typhoon Contest#01: G - Kimwipe Eater
writer: null
tester: leafirby, QCFium
Ported in accordance with the HackerRank terms. Some parts have been modified.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
null
leafirby