Advertisement
dimov

Untitled

Jan 3rd, 2013
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.90 KB | None | 0 0
  1. using System;
  2.  
  3. class BitBall
  4. {
  5.     static void Main()
  6.     {
  7.         int[] team1 = new int[8]{240,0,240,0,96,0,0,0};
  8.         int[] team2 = new int[8]{0,0,0,6,0,15,0,15};
  9.         int lCounter = 0;
  10.         int rCounter = 0;
  11.  
  12.         for (int i = 0; i < 8; i++)
  13.         {
  14.             team1[i] = int.Parse(Console.ReadLine());
  15.         }
  16.         for (int i = 0; i < 8; i++)
  17.         {
  18.             team2[i] = int.Parse(Console.ReadLine());
  19.         }
  20.  
  21.         for (int i = 0; i < 8; i++)
  22.         {
  23.             for (int j = 0; j < 8; j++)
  24.             {
  25.                 int mask = 1;
  26.                 mask <<= i;
  27.                 int maskN1 = mask & team1[j];
  28.                
  29.                 int maskN2 = mask & team2[j];
  30.                
  31.                 if (maskN1 == (1<<i) && maskN2 == (1<<i))
  32.                 {
  33.                     maskN1 = ~maskN1;
  34.                     team1[j] = maskN1 & team1[j];
  35.                     maskN2 = ~maskN2;
  36.                     team2[j] = maskN2 & team2[j];
  37.                 }
  38.             }
  39.         }
  40.  
  41.         for (int i = 7; i >= 0 ; i--)
  42.         {
  43.             for (int j = 7; j >= 0; j--)
  44.             {
  45.                 int mask = 1;
  46.                 mask <<= i;
  47.                 int maskN1 = mask & team1[j];
  48.  
  49.                 if (maskN1 > 0)
  50.                 {
  51.                     bool checker = true;
  52.                     for (int k = j+1; k < 8; k++)
  53.                     {
  54.                         int mask2 = 1;
  55.                         mask2 <<= i;
  56.                         int mask2N2 = mask2 & team2[k];
  57.                         if (mask2N2 > 0)
  58.                         {
  59.                             checker = false;
  60.                         }
  61.                     }
  62.                     if (checker == true)
  63.                     {
  64.                         lCounter++;
  65.                         j = -1;
  66.                         break;
  67.                     }
  68.                 }
  69.             }
  70.         }
  71.  
  72.         for (int i = 7; i >= 0; i--)
  73.         {
  74.             for (int j = 0; j < 8; j++)
  75.             {
  76.                 int mask = 1;
  77.                 mask <<= i;
  78.                 int maskN2 = mask & team2[j];
  79.  
  80.                 if (maskN2 > 0)
  81.                 {
  82.                     bool checker = true;
  83.                     for (int k = j - 1; k >=0 ; k--)
  84.                     {
  85.                         int mask1 = 1;
  86.                         mask1 <<= i;
  87.                         int mask1N1 = mask1 & team1[k];
  88.                         if (mask1N1 > 0)
  89.                         {
  90.                             checker = false;
  91.                         }
  92.                     }
  93.                     if (checker == true)
  94.                     {
  95.                         rCounter++;
  96.                         j = 8;
  97.                         break;
  98.                     }
  99.                 }
  100.             }
  101.         }
  102.         Console.WriteLine("{0}:{1}", lCounter,rCounter);
  103.     }
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement