Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class BitBall
- {
- static void Main()
- {
- int[,] matrixTop = new int[8, 8];
- for (int row = 0; row <= 7; row++)
- {
- int bitsTop = int.Parse(Console.ReadLine());
- for (int col = 0; col <= 7; col++)
- {
- matrixTop[row, col] = (bitsTop >> (7 - col)) & 1;
- }
- }
- int[,] matrixBottom = new int[8, 8];
- for (int row = 0; row <= 7; row++)
- {
- int bitsBottom = int.Parse(Console.ReadLine());
- for (int col = 0; col <= 7; col++)
- {
- matrixBottom[row, col] = (bitsBottom >> (7 - col)) & 1;
- }
- }
- int[,] matrixNew = new int[8, 8];
- for (int row = 0; row <= 7; row++)
- {
- for (int col = 0; col <= 7; col++)
- {
- if (matrixTop[row, 7 - col] == 1 && matrixBottom[row, 7 - col] == 0)
- {
- matrixNew[row, 7 - col] = 1;
- }
- else if (matrixTop[row, 7 - col] == 0 && matrixBottom[row, 7 - col] == 1)
- {
- matrixNew[row, 7 - col] = 2;
- }
- else
- {
- matrixNew[row, 7 - col] = 0;
- }
- }
- }
- int[,] matrixNewTop = matrixNew;
- for (int i = 0; i <= 7; i++)
- {
- //Attack Top - 1
- for (int col = 0; col <= 7; col++)
- {
- for (int row = 0; row < 7; row++)
- {
- if (matrixNew[row, col] == 1 && matrixNew[row + 1, col] != 2)
- {
- matrixNewTop[row, col] = 0;
- matrixNewTop[row + 1, col] = 1;
- }
- }
- }
- }
- int topResult = 0;
- for (int col = 0; col <= 7; col++)
- {
- if (matrixNewTop[7, col] == 1)
- {
- topResult++;
- }
- }
- int[,] matrixNewBottom = matrixNew;
- for (int i = 0; i <= 7; i++)
- {
- //Attack Bottom - 2
- for (int col = 0; col <= 7; col++)
- {
- for (int row = 7; row > 0; row--)
- {
- if (matrixNew[row, col] == 2 && matrixNew[row - 1, col] != 1)
- {
- matrixNewBottom[row, col] = 0;
- matrixNewBottom[row - 1, col] = 2;
- }
- }
- }
- }
- int bottomResult = 0;
- for (int col = 0; col <= 7; col++)
- {
- if (matrixNewBottom[0, col] == 2)
- {
- bottomResult++;
- }
- }
- Console.WriteLine("{0}:{1}", topResult, bottomResult);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement