Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- class Bombardent
- {
- static void Main()
- {
- string inputText = Console.ReadLine();
- int width = int.Parse(Console.ReadLine());
- string strBombs = Console.ReadLine();
- double rows = Math.Ceiling((double)inputText.Length / width);
- int rowsCount = (int)rows;
- int[] bombs = strBombs.Split(' ').Select(n => Convert.ToInt32(n)).ToArray();
- char[] text = inputText.ToCharArray();
- char[,] matrix = new char[rowsCount, width];
- int mark = 0;
- for (int i = 0; i < rowsCount; i++)
- {
- for (int j = 0; j < width; j++, mark++)
- {
- if (text.Length > mark)
- {
- matrix[i, j] = text[mark];
- }
- else
- {
- matrix[i, j] = ' ';
- }
- }
- }
- bombing(matrix, bombs);
- }
- static void bombing(char[,] matrix, int[] bombs)
- {
- List<char> output = new List<char>();
- for (int i = 0; i < bombs.Length; i++)
- {
- bool bombarded = false;
- int bomb = bombs[i];
- for (int j = 0; j < matrix.GetLongLength(0); j++)
- {
- if (matrix[j, bomb] != ' ')
- {
- bombarded = true;
- matrix[j, bomb] = ' ';
- }
- else if (bombarded)
- {
- break;
- }
- }
- }
- for (int i = 0; i < matrix.GetLongLength(0); i++)
- {
- for (int j = 0; j < matrix.GetLongLength(1); j++)
- {
- output.Add(matrix[i, j]);
- }
- }
- foreach (var chars in output)
- {
- Console.Write(chars);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement