CSharp · Console
using System;
public class BitBall
{
public static void Main()
{
const int width = 8;
const int height = 8;
string[,] matrixTop = new string[height, width];
string[,] matrixBottom = new string[height, width];
string[,] matrixPlayfield = new string[height, width];
// top team players
for (int row = 0; row < height; row++)
{
int topNumber = int.Parse(Console.ReadLine());
int position = 0;
for (int col = width - 1; col >= 0; col--)
{
int lastBit = (topNumber & (1 << position)) >> position;
if (lastBit != 0)
{
matrixTop[row, col] = "T";
}
else
{
matrixTop[row, col] = ".";
}
position++;
}
}
// bottom team players
for (int row = 0; row < height; row++)
{
int bottomNumber = int.Parse(Console.ReadLine());
int position = 0;
for (int col = width - 1; col >= 0; col--)
{
int lastBit = (bottomNumber & (1 << position)) >> position;
if (lastBit != 0)
{
matrixBottom[row, col] = "B";
}
else
{
matrixBottom[row, col] = ".";
}
position++;
}
}
// all players
for (int row = 0; row < height; row++)
{
for (int col = 0; col < width; col++)
{
if (matrixTop[row, col] == "T" && matrixBottom[row, col] == "B")
{
matrixPlayfield[row, col] = ".";
continue;
}
else if (matrixTop[row, col] == "T")
{
matrixPlayfield[row, col] = "T";
continue;
}
else if (matrixBottom[row, col] == "B")
{
matrixPlayfield[row, col] = "B";
continue;
}
else
{
matrixPlayfield[row, col] = ".";
}
}
}
//solution
int topTeamScore = 0;
int bottomTeamScore = 0;
//bottom team score check
for (int col = 0; col < height; col++)
{
for (int row = 0; row < width; row++)
{
if (matrixPlayfield[row, col] == "B")
{
bottomTeamScore++;
break;
}
else if (matrixPlayfield[row, col] == "T")
{
break;
}
}
}
//top team score check
for (int col = 0; col < height; col++)
{
for (int row = width - 1; row >= 0; row--)
{
if (matrixPlayfield[row, col] == "B")
{
break;
}
else if (matrixPlayfield[row, col] == "T")
{
topTeamScore++;
break;
}
}
}
Console.WriteLine("{0}:{1}", topTeamScore, bottomTeamScore);
}
}