Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- class Program
- {
- static void Main()
- {
- int[] first = new int[8]; //input data for top team
- int[] second = new int[8]; //input data for bottom team
- int[,] matrix1 = new int[8, 8]; //matrix to store top team
- int[,] matrix2 = new int[8, 8]; // matrix to store bottom team
- int[] score1 = new int[8]; //array to store score of top team to avoid more than 1 point for 1 column // top team score
- int[] score2 = new int[8]; //bottom team score
- //matrix 1
- for (int x = 0; x < 8; x++) //set 1 where are players
- {
- first[x] = int.Parse(Console.ReadLine()); //read from console
- for (int y = 0, reverse = 7; y < 8; y++, reverse--) //use reverse to denote player at exact position
- {
- if ((first[x] >> y & 1) == 1) //bitwise check for 1
- {
- matrix1[x, reverse] = 1; //fill matrix
- }
- }
- }
- //matrix2
- for (int x = 0; x < 8; x++)
- {
- second[x] = int.Parse(Console.ReadLine());
- for (int y = 0, reverse = 7; y < 8; y++, reverse--)
- {
- if ((second[x] >> y & 1) == 1)
- {
- matrix2[x, reverse] = 1;
- }
- }
- }
- //score 1
- bool check = true;
- for (int x = 0; x < 8; x++)
- {
- for (int y = 0; y < 8; y++)
- {
- if (matrix1[x, y] == 1) //player exist
- {
- if (x == 7) //useless row
- {
- score1[y]++;
- continue;
- }
- for (int i = x + 1; i < 8; i++) //check in matrix2 down for opposite team player
- {
- if (matrix2[i, y] == 1)
- {
- check = false; // set false if player exist
- }
- }
- if (check == true)
- {
- score1[y]++; // + 1 score for this column
- }
- }
- check = true;
- }
- }
- //score 2
- for (int x = 0; x < 8; x++)
- {
- for (int y = 0; y < 8; y++)
- {
- if (matrix2[x, y] == 1) //player exist
- {
- if (x == 0) //useless row
- {
- score2[y]++;
- continue;
- }
- for (int i = x - 1; i >= 0; i--) //check in matrix1 up for opposite player
- {
- if (matrix1[i, y] == 1)
- {
- check = false; //false if player exist
- }
- }
- if (check == true)
- {
- score2[y]++; //+1 score for this column
- }
- }
- check = true;
- }
- }
- ////print1
- //for (int x = 0; x < 8; x++)
- //{
- // for (int y = 0; y < 8; y++)
- // {
- // Console.Write(matrix1[x, y]);
- // }
- // Console.WriteLine();
- //}
- //Console.WriteLine();
- ////print2
- //for (int x = 0; x < 8; x++)
- //{
- // for (int y = 0; y < 8; y++)
- // {
- // Console.Write(matrix2[x, y]);
- // }
- // Console.WriteLine();
- //}
- //Console.WriteLine();
- //score1
- int res1 = 0;
- foreach (var item in score1) //calc score
- {
- if (item > 0)
- {
- res1++;
- }
- }
- //score2
- int res2 = 0;
- foreach (var item in score2)
- {
- if (item > 0)
- {
- res2++;
- }
- }
- Console.WriteLine(res1 + ":" + res2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement