Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- class TrifonQuest
- {
- static void Main()
- {
- long health = long.Parse(Console.ReadLine());
- int[] tokens = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
- int rows = tokens[0];
- int cols = tokens[1];
- char[][] matrix = new char[rows][];
- for (int i = 0; i < rows; i++)
- {
- matrix[i] = Console.ReadLine().ToCharArray();
- }
- int row = 0;
- int col = 0;
- int dir = 1;
- long turns = 0;
- bool alive = true;
- int steps = 0;
- while (col != cols)
- {
- while (true)
- {
- switch (matrix[row][col])
- {
- case 'F':
- health = health - turns / 2;
- turns++;
- break;
- case 'H':
- health = health + turns / 3;
- turns++;
- break;
- case 'T':
- turns = turns + 2;
- turns++;
- break;
- case 'E':
- turns++;
- break;
- default:
- break;
- }
- steps++;
- if (health <= 0)
- {
- alive = false;
- Console.WriteLine($"Died at: [{row}, {col}]");
- }
- if (alive==false)
- {
- break;
- }
- if (steps == rows*cols)
- {
- Console.WriteLine("Quest completed!");
- Console.WriteLine($"Health: {health}");
- Console.WriteLine($"Turns: {turns}");
- }
- row += dir;
- if (row == rows)
- {
- row--;
- break;
- }
- else if (row == -1)
- {
- row++;
- break;
- }
- }
- if (alive==false)
- {
- break;
- }
- dir = -dir;
- col++;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment