Advertisement
Guest User

TextBombardment

a guest
May 26th, 2015
342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.24 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. class TextBombardment
  6. {
  7.     static void Main()
  8.     {
  9.         string input = Console.ReadLine();
  10.         int cols = int.Parse(Console.ReadLine());
  11.         string bombs = Console.ReadLine();
  12.                
  13.         int rows = input.Length / cols + 1;
  14.                
  15.         List<char> charList = input.ToList();
  16.         for (int i = 0; i < cols; i++)
  17.         {
  18.             charList.Add(' ');
  19.         }
  20.         char[] charArr = charList.ToArray();
  21.         int[] bombsArr = bombs.Split(' ').Select(int.Parse).ToArray();
  22.  
  23.         for (int i = 0; i < bombsArr.Length; i++)
  24.         {
  25.             charArr[bombsArr[i]] = ' ';
  26.             bombsArr[i] += cols;
  27.         }
  28.  
  29.         for (int j = 0; j < rows - 1; j++)
  30.         {
  31.             for (int i = 0; i < bombsArr.Length; i++)
  32.             {
  33.                 if (charArr[bombsArr[i]] != ' ')
  34.                 {
  35.                     charArr[bombsArr[i]] = ' ';
  36.                     if (bombsArr[i] + cols <= charArr.Length)
  37.                     {
  38.                         bombsArr[i] += cols;
  39.                     }
  40.                 }
  41.             }
  42.         }
  43.  
  44.         Console.WriteLine(new string(charArr).Trim());
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement