Loading...

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

nikolova.irina.n avatar nikolova.irina.n 0 Точки

02. Selling - C# Advanced Retake Exam - 16 December 2020

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

Вече няколко часа мъча тази задачка и не мога да я докарам до 100/100.

Гърми ми с Time limit и както и да я преправя не получавам повече от 90/100.

Предполагам, че грешката ми е в частта където се прехвърлям между pillar-ите.

Ще съм много благодарна ако някой ми даде идея за оптимизирането на кода. smiley

 

Ето и кода: https://pastebin.com/HZhu0eds

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

Условието:

Selling

You successfully started your cooking journey, so now you need to sell the products from your basket  in the bakery in order to collect your price.

You will be given an integer n for the size of the bakery with square shape. On the next n lines, you will receive the rows of the bakery. You will be placed on a random position, marked with the letter 'S'. On random positions there will be clients, marked with a single digit. There may also be pillars. Their count will be either 0 or 2 and they are marked with the letter - 'O'. All of the empty positions will be marked with '-'.

Each turn, you will be given commands for the your movement. Move commands will be: "up", "down", "left", "right". If you move to a client, you collects the price equal to the digit there and the client disappears. If you move to a pillar, you move on the position of the other pillar and then both pillars disappear. If you go out of the bakery, you disappear from the bakery and you are out of there. You need at least 50 dollars to rent your own Bakery

When you are out of the bakery or you collect enough money, the program 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 a move command.

Output

  • On the first line:
    • If the player goes to the void, print: "Bad news, you are out of the bakery."
    • If the player collects enough star power, print: "Good news! You succeeded in collecting enough money!"
  • On the second line print all star power collected: "Money: {money}"
  • In the end print the matrix.

Constraints

  • The size of the square matrix will be between [2…10].
  • There will always be 0 or 2 pillars, marked with the letter - 'O'.
  • Your position will be marked with 'S'.
  • You will always go out of the bakery or collect enough money.

Examples

Input

Output

Comments

5

SO---

-----

-----

-----

----O

right

right

Bad news, you are out of the bakery.

Money: 0

-----

-----

-----

-----

-----

The first command is right. You move to one of the pillars and then appears on the other side of it (4,4).

The bakery looks like this after the first command:

-----

-----

-----

-----

----S

The second command is right. You go of the bakery.

6

S98---

99----

666666

------

--77--

-6-6-6

right

right

down

left

left

down

right

right

Good news! You succeeded in collecting enough money!

Money: 53

------

------

--S666

------

--77--

-6-6-6

Here we have no pillars and bakery rich of clients.

You manage to collect enough money without going out of the bakery.

The clients you have selled food to have disappeared and we can see where you were when you collected the last neeeded money (2,2).

 

 

Тагове:
0
C# Advanced 04/02/2021 08:05:28
yanchev.ilian avatar yanchev.ilian 24 Точки

https://pastebin.com/gmtMqrX5 - 100/100

Предлагам още едно малко по - различно решение, с иреч използвал съм List<int[]> вместо Tuple<int,int> относно съхранението на pillars.

Надявам се да съм бил полезен.

 

 

Поздрави,

Илиян Янчев

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