Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- class Program
- {
- static void Main()
- {
- string text = Console.ReadLine();
- int length = text.Length;
- int width = int.Parse(Console.ReadLine());
- int height = (length / width);
- height += text.Length % width == 0 ? 0 : 1;
- string bombs = Console.ReadLine();
- int[] bombCols = bombs.Split(' ').Select(int.Parse).ToArray();
- int[] nbombCols = bombCols.Distinct().ToArray();
- //for (int i = 0; i < nbombCols.Length; i++)
- //{
- // Console.WriteLine(nbombCols[i]);
- //}
- char[,] arr = new char[height, width];
- int index = 0;
- for (int i = 0; i < height; i++)
- {
- for (int j = 0; j < width; j++)
- {
- arr[i, j] = text[index++];
- if (index >= length)
- {
- break;
- }
- }
- }
- for (int i = 0; i < bombCols.Length; i++)
- {
- int bomb = int.Parse(bombCols[i].ToString());
- for (int b = 0; b < height; b++)
- {
- int row = b;
- int col = bomb;
- if (arr[b, bomb] == ' ')
- {
- continue;
- }
- arr[b, bomb] = ' ';
- if (b + 1 < height)
- {
- if (arr[b + 1, bomb] == ' ')
- {
- break;
- }
- }
- }
- }
- /*
- for (int i = 0; i < bombCols.Length; i++)
- {
- if (bombCols[i] == -1)
- {
- continue;
- }
- for (int j = 0; j < height; j++)
- {
- if (arr[j, bombCols[i]] == ' ' && j > 0)
- {
- break;
- }
- else
- {
- arr[j, bombCols[i]] = ' ';
- }
- }
- }*/
- for (int i = 0; i < height; i++)
- {
- for (int j = 0; j < width; j++)
- {
- char letter = arr[i, j];
- if (letter != '\0')
- {
- Console.Write(arr[i, j]);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment