Loading...

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

PetarNeshkov5360 avatar PetarNeshkov5360 23 Точки

02. Garden-C# Advanced Exam - 25 October 2020

Здравейте! От няколко часа се бъхтя с тази задача, но не мога да си открия грешката, дава ми 62/100. Ако някой ми открие грешката, ще бъда благодарен!

Решение: https://pastebin.com/Ma5ij54L

Условие:

                                                       Garden

Furion loves nature and that is why he has a beautiful square garden. He wants to plant it with magical flowers, so it can be even more beautiful. No one knows why, but he actually needs a software program to do that, that is why you'll write one for him.

You will be given N and Mintegers, indicating the dimensions of the square garden. The garden is empty at the beginning – it has no flowers. Furion wants every place for a flower to be presented with a zero (0) when it is empty. After you finish creating the garden, you will start receiving two integers – Row and Column, separated by a single space – which represent the position at which Furion currently plants a flower. If you receive a position, which is outside of the garden, you should print "Invalid coordinates." and move on with the next position. This happens until you receive the command "Bloom Bloom Plow”. When you receive that input, all planted flowers should bloom.

The flowers are magical. When a flower blooms it instantly blooms flowers to all places to its left, right, up, and down, increasing their value with 1. Flowers can bloom multiple times, and each time the flower blooms – it becomes more and more beautiful, which means its value increases by 1.

Input

  • On the first line of input you will receive two integers, separated by a single space – indicating the dimensions of the garden.
  • On the next several lines you will be receiving two integers separated by a single space – indicating the position at which Furion currently plants a flower.
  • When you receive the input line "Bloom Bloom Plow” the input sequence should end.

Output

  • Print "Invalid coordinates." each time you receive positions outside the garden.
  • The output is simple. Print the whole garden – each row of it on a new line, and each column – separated by a single space.

Constraints

  • The dimensions of the matrix (N and M) will contains be integers in the range [3, 500].
  • The amount of input commands will be in the range [0, N * M].
  • Flowers will always be planted on empty places.

Examples

Input

Output

Comment

5 5

1 1

3 3

Bloom Bloom Plow

0 1 0 1 0

1 1 1 2 1

0 1 0 1 0

1 2 1 1 1

0 1 0 1 0

The garden has 5 rows and 5 columns.

They are all 0 at the beginning.

The planted flowers are at [1, 1] and [3, 3].

The affected places are:

0 0 0 0 0

0 0 0 0 0

0 0 0 0 0

0 0 0 0 0

0 0 0 0 0

We receive the blooming command and we bloom the flowers.

First, we reach the first flower, and we bloom it, increasing all affected fields' value with 1.

0 1 0 0 0

1 1 1 1 1

0 1 0 0 0

0 1 0 0 0

0 1 0 0 0

Then we bloom the second flower, and we increase all affected fields' (even those from the first flower) value with 1.

0 1 0 1 0

1 1 1 2 1

0 1 0 1 0

1 2 1 1 1

0 1 0 1 0

4 4

0 0

3 3

1 1

2 2

Bloom Bloom Plow

1 2 2 2

2 1 2 2

2 2 1 2

2 2 2 1

 

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

Здравей, пропуснал си "Invalid coordinates."  Точката накрая :) 

0
GecataFTW avatar GecataFTW 0 Точки

Много се смях след като се чудих кво е 20м xD

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