Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Program
- {
- static void Main()
- {
- int[,] matrix = new int[8, 16];
- for (int i = 0; i < 8; i++)
- {
- int number = int.Parse(Console.ReadLine());
- for (int j = 0; j < 16; j++)
- {
- matrix[i, j] = (number >> j) & 1;
- }
- }
- int score = 0;
- for (int col = 8; col < 16; col++)
- {
- for (int row = 0; row < 8; row++)
- {
- if (matrix[row, col] == 1)
- {
- int cRow = row;
- int cCol = col;
- matrix[row, col] = 0;
- string direction = "up";
- int path = 0;
- while (true)
- {
- if ((matrix[cRow, cCol] == 1) && cCol < 8)
- {
- int piggies = 0;
- for (int i = cCol + 1; i >= cCol - 1; i--)
- {
- for (int j = cRow - 1; j <= cRow + 1; j++)
- {
- if (i >= 0 && i < 8 && j >= 0)
- {
- if (matrix[j, i] == 1)
- {
- matrix[j, i] = 0;
- piggies += 1;
- }
- }
- if (j + 1 == 8) break;
- }
- if (i - 1 == -1) break;
- }
- score += piggies * path;
- path = 0;
- break;
- }
- if (direction == "up")
- {
- if (cRow == 0)
- {
- direction = "down";
- cCol--;
- cRow++;
- }
- else
- {
- cRow--;
- cCol--;
- }
- }
- else if (direction == "down")
- {
- if (cCol == 0 || cRow == 7)
- {
- break;
- }
- cRow++;
- cCol--;
- }
- path++;
- }
- }
- }
- }
- string result = " Yes";
- for (int i = 0; i < 8; i++)
- {
- for (int j = 0; j < 8; j++)
- {
- if (matrix[i, j] == 1)
- {
- result = " No";
- break;
- }
- }
- }
- Console.WriteLine(score+result);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement