Loading...
ElicaAndreeva avatar ElicaAndreeva 5 Точки

Re-Volt Java Advanced Exam - 22 Feb 2020

Здравейте, не мога да си открия грешките в задача 02. Re-Volt от Java Advanced Exam - 22 Feb 2020. Проблемни са последните три теста и резултат в judge 72/100. 

https://judge.softuni.org/Contests/Practice/Index/2036#1

https://pastebin.com/19argwja

Re-Volt
You will be given an integer N for the size of the square matrix and then an integer for the count of commands. On the next n lines, you will receive the rows of the matrix. The player starts at a random position (the player is marked with "f") and all of the empty slots will be filled with "-" (dash). The goal is to reach the finish mark which will be marked with "F". On the field there can also be bonuses and traps. Bonuses are marked with "B" and traps are marked with "T".
Each turn you will be given commands for the player’s movement. If the 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 on the first row. 
If the player steps on a bonus, he should move another step forward in the direction he is going. If the player steps on a trap, he should move a step backwards.
When the player reaches the finish mark or the count of commands is reached, the game ends.
Input
On the first line, you are given the integer N – the size of the square matrix.
On the second you are given the count of commands.
The next N lines hold the values for every row.
On each of the next lines you will get commands for movement directions.
Output
If the player reaches the finish mark, print: 
"Player won!"
If the player reaches the commands count and hasn’t reached the finish mark print:
"Player lost!"
In the end print the matrix.
Constraints
The size of the matrix will be between [2…20].
The players will always be indicated with "f".
If the player steps on the finish mark at the same time as his last command, he wins the game.
Commands will be in the format up, down, left or right.
There won't be a case where you bypass the finish while you are on a trap or a bonus.
A trap will never place you into a bonus or another trap and a bonus will never place you into a trap or another bonus.

Examples
 
Input    Output    Comments       
5
5
-----
-f---
-B---
--T--
-F---
down
right
down    Player won!
-----
-----
-B---
--T--
-f---    The first command is down so f moves down. On turn 1, the player steps on a bonus and does an additional step. On turn 2, the player steps on a trap and goes a step back. After each turn the field is:
  1      2      3   
-----  -----  -----
-----  -----  -----
-B---  -B---  -B---
-fT--  -fT--  --T--
-F---  -F---  -f---
On turn 3 f reaches the finish 'F' and wins the game.       
4
3
----
-f-B
--T-
---F
up
up
left    Player lost!
----
---B
--T-
f--F    The first command is up so f moves up and the new player position is (0,1). The next command is up again, so the player goes out of the matrix and comes back from the other side at (3,1). Then the command is left, so the end position is (3,0) which is not the finish mark, so the player has lost.     
 

Тагове:
0
Java Advanced 21/10/2021 19:18:41
ElicaAndreeva avatar ElicaAndreeva 5 Точки
Промених изхода и сега съм на 90/100 точки 
if (reachFinish) {

    System.out.println("Player won!");

} else  {

    System.out.println("Player lost!");

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