Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace TrifonsQuest
- {
- public class TrifonsQuest
- {
- public static void Main()
- {
- long trifonsHealth = long.Parse(Console.ReadLine());
- int[] rowsAndCols = Console.ReadLine()
- .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
- .Select(int.Parse)
- .ToArray();
- char[,] matrix = new char[rowsAndCols[0], rowsAndCols[1]];
- for (int currRow = 0; currRow < rowsAndCols[0]; currRow++)
- {
- string rowLayout = Console.ReadLine().ToLower();
- for (int currCol = 0; currCol < rowLayout.Length; currCol++)
- {
- matrix[currRow, currCol] = rowLayout[currCol];
- }
- }
- int countOfTurns = 0;
- int row = 0;
- int col = 0;
- bool trifonIsDead = false;
- while (col < matrix.GetLength(1))
- {
- while (row != matrix.GetLength(0))
- {
- char symbol = matrix[row, col];
- if (symbol == 'f')
- {
- int hpLost = countOfTurns / 2;
- trifonsHealth -= hpLost;
- if (trifonsHealth <= 0)
- {
- trifonIsDead = true;
- break;
- }
- }
- else if (symbol == 'h')
- {
- int hpGained = countOfTurns / 3;
- trifonsHealth += hpGained;
- }
- else if (symbol == 't')
- {
- countOfTurns += 2;
- }
- countOfTurns++;
- row++;
- }
- if (trifonIsDead)
- {
- break;
- }
- row--;
- col++;
- while (row != -1 && col != matrix.GetLength(1))
- {
- char symbol = matrix[row, col];
- if (symbol == 'f')
- {
- int hpLost = countOfTurns / 2;
- trifonsHealth -= hpLost;
- if (trifonsHealth <= 0)
- {
- trifonIsDead = true;
- break;
- }
- }
- else if (symbol == 'h')
- {
- int hpGained = countOfTurns / 3;
- trifonsHealth += hpGained;
- }
- else if (symbol == 't')
- {
- countOfTurns += 2;
- }
- countOfTurns++;
- row--;
- }
- if (trifonIsDead)
- {
- break;
- }
- row = 0;
- col++;
- }
- if (trifonIsDead)
- {
- Console.WriteLine($"Died at: [{row}, {col}]");
- return;
- }
- Console.WriteLine("Quest completed!");
- Console.WriteLine($"Health: {trifonsHealth}");
- Console.WriteLine($"Turns: {countOfTurns}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement