Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- class Program
- {
- static void Main()
- {
- int pairs = int.Parse(Console.ReadLine());
- int[] oldboard = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, };
- int x; int y;
- List<int> newboard = new List<int>{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- List<int> coordinates = new List<int>();
- for (int i = 0; i < pairs; i++)
- {
- x = int.Parse(Console.ReadLine());
- y = int.Parse(Console.ReadLine());
- oldboard[x] |= (1 << y);
- coordinates.Add(x);
- coordinates.Add(y);
- }
- foreach (var row in oldboard)
- {
- Console.WriteLine(Convert.ToString(row, 2).PadLeft(10, '0'));
- }
- for (int red = 0; red < 10; red++)// minavam prez vcseki edin bit
- {
- //foreach (var row in newboard)
- //{
- // Console.WriteLine(Convert.ToString(row, 2).PadLeft(10, '0'));
- //}
- //Console.WriteLine();
- for (int kol = 9; kol >=0; kol--)
- {
- int currentbit = (oldboard[red] & (1 << kol)) == 0 ? 0 : 1;
- int checkedbit;
- int countones = 0;
- int startred = Math.Max(red - 1, 0);// opredelqv koi susedni bitove da proverqvam
- int endred = Math.Min(red + 1, 9);
- int startkol = Math.Min(kol + 1, 9);
- int endkol = Math.Min(kol - 1, 0);
- for (int k = startred; k < endred; k++)
- {
- for (int l = endkol; l > startkol; l--)
- {
- if (k==red&&l==kol)
- {
- continue;
- }
- checkedbit = (oldboard[k]&(1<<l)) == 0 ? 0 : 1;
- if (checkedbit==1)
- {
- countones++;
- }
- }
- }
- if (currentbit == 1)
- {
- if (countones < 2 || 3 < countones)
- {
- newboard[red] &= ~(1 << kol);
- }
- }
- else
- {
- if (countones == 3)
- {
- newboard[red] |= (1 << kol);
- }
- }
- }
- }
- Console.WriteLine(newboard[2]); //pravq proverka kolko tretoto 4islo -zero testa dava razlika samo v nego
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment