Loading...

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

Denislava91 avatar Denislava91 5 Точки

10. *Radioactive Mutant Vampire Bunnies C# Advanced, Multidimensional Arrays

Здравейте, колеги,

 

След неуспешна борба със следната задача, ви моля за помощ:) Откровено не знам какъв е проблемът, реално решението ми работи , но получавам 40/100. Гледах и решението по време на упражненията от предния курс и реално съм си я сравнила , взаимствала и подобни, но Джъдж гърми на 6 теста. Много ще съм благодарна, ако споделите мнение: https://pastebin.com/EW2ac4xY.

Предварително благодаря:)

Поздрави,

Дени

 

1.   *Radioactive Mutant Vampire Bunnies

Browsing through GitHub, you come across an old JS Basics teamwork game. It is about very nasty bunnies that multiply extremely fast. There’s also a player that has to escape from their lair. You really like the game, so you decide to port it to C# because that’s your language of choice. The last thing that is left is the algorithm that decides if the player will escape the lair or not.

First, you will receive a line holding integers N and M, which represent the rows and columns in the lair. Then you receive N strings that can only consist of “.”, “B”, “P”. The bunnies are marked with “B”, the player is marked with “P”, and everything else is free space, marked with a dot “.”. They represent the initial state of the lair. There will be only one player. Then you will receive a string with commands such as LLRRUUDD – where each letter represents the next move of the player (Left, Right, Up, Down).

After each step of the player, each of the bunnies spread to the up, down, left and right (neighboring cells marked as “.” changes their value to B). If the player moves to a bunny cell or a bunny reaches the player, the player has died. If the player goes out of the lair without encountering a bunny, the player has won.

When the player dies or wins, the game ends. All the activities for this turn continue (e.g. all the bunnies spread normally), but there are no more turns. There will be no stalemates where the moves of the player end before he dies or escapes.

Finally, print the final state of the lair with every row on a separate line. On the last line, print either “dead: {row} {col}” or “won: {row} {col}”. Row and col are the coordinates of the cell where the player has died or the last cell he has been in before escaping the lair.

Input

  • On the first line of input, the numbers N and M are received – the number of rows and columns in the lair
  • On the next N lines, each row is received in the form of a string. The string will contain only “.”, “B”, “P”. All strings will be the same length. There will be only one “P” for all the input
  • On the last line, the directions are received in the form of a string, containing “R”, “L”, “U”, “D”

Output

  • On the first N lines, print the final state of the bunny lair
  • On the last line, print the outcome – “won:” or “dead:” + {row} {col}

Constraints

  • The dimensions of the lair are in range [3…20]
  • The directions string length is in range [1…20]

Examples

Input

Output

5 8

.......B

...B....

....B..B

........

..P.....

ULLL

BBBBBBBB

BBBBBBBB

BBBBBBBB

.BBBBBBB

..BBBBBB

won: 3 0

 

4 5

.....

.....

.B...

...P.

LLLLLLLL

.B...

BBB..

BBBB.

BBB..

dead: 3 1

 

 

 

Тагове:
0
C# Advanced
MartinBG avatar MartinBG 4803 Точки
Best Answer

На пръв поглед забелязвам, че при победа на играча, ако заек заеме последната му позиция, ще се отпечата, че играчът е загубил.

Променете редове 123-131 от:

            if (isDead)
            {
                Console.WriteLine($"dead: {playerRow} {playerCol}");
            }
 
            else if (isWon)
            {
                Console.WriteLine($"won: {playerRow} {playerCol}");
            }

на:

            if (isWon)
            {
                Console.WriteLine($"won: {playerRow} {playerCol}");
            }
            else  if (isDead)
            {
                Console.WriteLine($"dead: {playerRow} {playerCol}");
            }

и още един от тестовете ще мине (50/100).

 

Тази задача е често обсъждана във форума: теми с решения

Разгледате ги и най-вероятно сама ще откриете какво друго липсва в решението Ви.

0
21/05/2020 18:50:33
Denislava91 avatar Denislava91 5 Точки

Благодаря, MartinBG,

Намерих тестовете  и ще ги пробвам сега.

Поздрави.

Дени

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