using System; using System.Linq; namespace Target_Practice { class Program { private static bool IsInsideRadius(int checkRow, int checkCol, int impactRow, int impactCol, int shotRadius) { int deltaRow = checkRow - impactRow; int deltaCol = checkCol - impactCol; bool isInRadius = deltaRow * deltaRow + deltaCol * deltaCol <= shotRadius * shotRadius; return isInRadius; } static void Main(string[] args) { var size = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray(); var snake = Console.ReadLine().ToCharArray(); var shotParameters = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray(); var matrix = new string[size[0], size[1]]; var impactRow = shotParameters[0]; var impactCol = shotParameters[1]; var radius = shotParameters[2]; var currentRow = 0; var snakeIndex = 0; for (int row = matrix.GetLength(0) - 1; row >= 0; row--, currentRow++) { if (currentRow % 2 == 0) { for (int col = matrix.GetLength(1) - 1; col >= 0; col--) { if (snakeIndex == snake.Length) { snakeIndex = 0; } matrix[row, col] = snake[snakeIndex].ToString(); snakeIndex++; } } else { for (int col = 0; col < matrix.GetLength(1); col++) { if (snakeIndex == snake.Length) { snakeIndex = 0; } matrix[row, col] = snake[snakeIndex].ToString(); snakeIndex++; } } } for (int row = 0; row < matrix.GetLength(0); row++) { for (int col = 0; col < matrix.GetLength(1); col++) { if (IsInsideRadius(row,col,impactRow,impactCol,radius)) { matrix[row, col] = " "; } } } for (int row = matrix.GetLength(0) - 1; row >= 0; row--) { for (int col = 0; col < matrix.GetLength(1); col++) { if (matrix[row,col] != " ") { continue; } var curRow = row-1; while (curRow>=0) { if (matrix[curRow,col] != " ") { matrix[row, col] = matrix[curRow, col]; matrix[curRow, col] = " "; break; } curRow--; } } } for (int i = 0; i < matrix.GetLength(0); i++) { for (int j = 0; j < matrix.GetLength(1); j++) { Console.Write(matrix[i, j]); } Console.WriteLine(); } } } }