|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|2 초||512 MB||1||1||1||100.000%|
2048 is a sliding block puzzle game. The game's objective is to slide numbered tiles on a grid to combine them to create a tile with the number 2048. It is played on a 4×4 grid, with numbered tiles that slide smoothly when the player moves them using the four arrow keys. Every turn, a new tile will randomly appear in an empty spot on the board with a value of either 2 or 4. Tiles slide as far as possible in the chosen direction until they are stopped by either another tile or the edge of the grid. If two tiles of the same number collide while moving, they will merge into a tile with the total value of the two tiles that collided. The resulting tile cannot merge with another tile again in the same move. The user's score starts at zero, and is incremented whenever two tiles combine, by the value of the new tile.
Write a program that takes the current user score, M number of moves and random appeared numbers (and their location on grid) and the current grid values as inputs and print the final score of the user.
First line contains current user score. 0 <= S
Next line contains M next moves. 0 <= M
Next line contains current grid content in a flatten string.
Print the user score after given moves.
200 L213D202R211D210D200D212R410R200D401L212 0 2 0 0 0 4 0 0 2 8 2 0 8 32 16 2
Note the user score is 200
The below is 2048 grid for the input "0 2 0 0 0 4 0 0 2 8 2 0 8 32 16 2":
Input moves are: L213,D202,R211,D210,D200,D212,R410,R200,D401,L212
Down, a new 2 at 0x2
4 at 3x3
Right, a new 2 at 1x1
4 at 0x3
Down, a new 2 at 1x0
8 at 1x3, 4 at 2x1
Down, a new 2 at 0x0
Down, a new 2 at 1x2
4 at 2x0
Down, a new 4 at 1x0
8 at 2x1
Right, a new 2 at 0x0
16 at 2x2
Down, a new 4 at 0x1
32 a 3x2
Left, a new 2 at 1x2
4 at 2x2, 64 at 3x1
Add the merge scores together: 4 + 4 + 8 + 4 + 4 + 8 + 16 + 32 + 4 + 64 = 148
Add 148 to starting score: 200 + 148 = 348