Loading...

Във форума е въведено ограничение, което позволява на потребителите единствено да разглеждат публикуваните въпроси.

dido1092 avatar dido1092 38 Точки

02. Tron Racers

Привет, бих желал малко помощ, въпросната задача ми дава само 30/100 в Judge!

Моето решение: https://pastebin.com/F6Ze3kMU

Линк към Judge: https://judge.softuni.bg/Contests/Practice/Index/1553#1

Условие на задачата

Tron Racers

The new TRON tournament has started and you have to keep track of the players on the field.

You will be given an integer n for the size of the matrix. On the next n lines, you will receive the rows of the matrix. The game starts with two players (first player is marked with "f" and the second player is marked with "s") in random positions and all of the empty slots will be filled with "*".

Each turn you will be given commands respectively for each player’s movement. The first command is for the first player and the second is for the second player. After a player moves, he leaves a trail on the field. The symbol that marks the trail is the same as the player's symbol. If a player goes out of the matrix, he comes in from the other side. For example, if the player is on 0, 0 and the next command is left, he goes to the last spot in the first row.

If a player steps on the other player's trail, he dies. When a player dies in the field, you should write "x" in the position where he died.

When only one of the players is left alive on the field the game ends.

Input

  • On the first line, you are given the integer N – the size of the square matrix.
  • The next N lines holds the values for every row.
  • On each of the next lines you will get two commands separated by space .

Output

  • In the end print the matrix.

Constraints

  • The size of the matrix will be between [2…20].
  • There will always be exactly two players.
  • The players will always be indicated with "f" for the first one and "s" for the second one.
  • There will always be enough commands to finish the game with one player alive.
  • There will not be commands where a player goes back and steps on his trail from the previous turn.
  • Commands will be in the format up, down, left or right.

Examples

Input

Output

Comments

5

***f*

**s**

*****

*****

*****

down down

right down

down right

down down

down left

left left

***f*

**sff

**s*f

**ssf

**sxf

The first command is down down so f moves down and s moves down. After each turn the field is:

  1      2      3      4      5      6

***f*  ***f*  ***f*  ***f*  ***f*  ***f*

**sf*  **sff  **sff  **sff  **sff  **sff

**s**  **s**  **s*f  **s*f  **s*f  **s*f

*****  **s**  **ss*  **ssf  **ssf  **ssf

*****  *****  *****  ***s*  **ssf  **sxf

On turn 6 f crashes into s's trail and f dies. As there is only one player left alive s is the only one left he is the winner.

4

*f**

****

**s*

****

down up

down right

right right

*f**

*fss

*fx*

****

 

Тагове:
0
C# Advanced
Можем ли да използваме бисквитки?
Ние използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Можете да се съгласите с всички или част от тях.
Назад
Функционални
Използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Използваме „сесийни“ бисквитки, за да Ви идентифицираме временно. Те се пазят само по време на активната употреба на услугите ни. След излизане от приложението, затваряне на браузъра или мобилното устройство, данните се трият. Използваме бисквитки, за да предоставим опцията „Запомни Ме“, която Ви позволява да използвате нашите услуги без да предоставяте потребителско име и парола. Допълнително е възможно да използваме бисквитки за да съхраняваме различни малки настройки, като избор на езика, позиции на менюта и персонализирано съдържание. Използваме бисквитки и за измерване на маркетинговите ни усилия.
Рекламни
Използваме бисквитки, за да измерваме маркетинг ефективността ни, броене на посещения, както и за проследяването дали дадено електронно писмо е било отворено.