Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace Advanced
- {
- class Program
- {
- static void Main(string[] args)
- {
- var dimentions = Console.ReadLine()
- .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
- .Select(int.Parse)
- .ToArray();
- int rows = dimentions[0];
- int cols = dimentions[1];
- var matrix = new int[rows][];
- for (int row = 0; row < rows; row++)
- {
- matrix[row] = new int[cols];
- }
- var bomb = Console.ReadLine()
- .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
- .Select(int.Parse)
- .ToArray();
- int bombRow = bomb[0];
- int bombCol = bomb[1];
- int radius = bomb[2];
- for (int row = 0; row < rows; row++)
- {
- for (int col = 0; col < cols; col++)
- {
- double distance = Math.Sqrt(Math.Pow(row - bombRow, 2) + Math.Pow(col - bombCol, 2));
- if (distance <= radius)
- {
- matrix[row][col] = 1;
- }
- }
- }
- var secondMatrix = new int[cols][];
- for (int row = 0; row < cols; row++)
- {
- secondMatrix[row] = new int[rows];
- for (int col = 0; col < rows; col++)
- {
- secondMatrix[row][col] = matrix[col][row];
- }
- secondMatrix[row] = secondMatrix[row].OrderByDescending(x => x).ToArray();
- }
- for (int row = 0; row < rows; row++)
- {
- for (int col = 0; col < cols; col++)
- {
- matrix[row][col] = secondMatrix[col][row];
- }
- }
- Console.WriteLine(string.Join(Environment.NewLine, matrix.Select(r => string.Join("", r))));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement