Advertisement
EvlogiHr

BitBall

Dec 29th, 2012
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.82 KB | None | 0 0
  1. using System;
  2.  
  3. class BitBall
  4. {
  5.     static void Main()
  6.     {
  7.         int[,] top = new int[8, 8];
  8.         int[,] bot = new int[8, 8];
  9.         int[,] all = new int[8, 8];
  10.  
  11.         for (int row = 0; row < 16; row++)
  12.         {
  13.             int num = int.Parse(Console.ReadLine());
  14.             for (int col = 0; col < 8; col++)
  15.             {
  16.                 if (row < 8)
  17.                 {
  18.                     top[row, col] = (num >> col) & 1;
  19.                     all[row, col] = top[row, col];
  20.                 }
  21.                 else
  22.                 {
  23.                     bot[row - 8, col] = (num >> col) & 1;
  24.                     all[row - 8, col] ^= bot[row - 8, col];
  25.                 }
  26.             }
  27.         }
  28.  
  29.         int scoreTop = 0;
  30.         int scoreBot = 0;
  31.  
  32.         for (int col = 0; col < 8; col++)
  33.         {
  34.             for (int row = 0; row < 8; row++)
  35.             {
  36.                 if (top[row,col] != 0 && all[row,col] != 0)
  37.                 {
  38.                     while (row < 7 && all[row + 1, col] == 0)
  39.                     {
  40.                         row++;
  41.                     }
  42.                     if (row == 7)
  43.                     {
  44.                         scoreTop++;
  45.                     }
  46.                 }
  47.             }
  48.         }
  49.  
  50.         for (int col = 0; col < 8; col++)
  51.         {
  52.             for (int row = 7; row >= 0; row--)
  53.             {
  54.                 if (bot[row, col] != 0 && all[row, col] != 0)
  55.                 {
  56.                     while (row > 0 && all[row - 1,col] == 0)
  57.                     {
  58.                         row--;
  59.                     }
  60.                     if (row == 0)
  61.                     {
  62.                         scoreBot++;
  63.                     }
  64.                 }
  65.             }
  66.         }
  67.  
  68.         Console.WriteLine("{0}:{1}", scoreTop, scoreBot);
  69.     }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement