Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- public class TestProject
- {
- private 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 };
- for (int i = 0; i < pairs; i++)// minavam prez vcseki edin bit
- {
- //foreach (var row in newboard)
- //{
- // Console.WriteLine(Convert.ToString(row, 2).PadLeft(10, '0'));
- //}
- //Console.WriteLine();
- x = int.Parse(Console.ReadLine());
- y = int.Parse(Console.ReadLine());
- oldboard[x] |= (1 << y);
- newboard[x] |= (1 << y);
- }
- for (int red = 0; red < 10; red++) // minavam prez vcseki edin bit
- {
- for (int kol = 9; kol >= 0; kol--)
- {
- int currentbit = (newboard[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.Max(kol - 1, 0);
- int endkol = Math.Min(kol + 1, 9);
- for (int k = startred; k <= endred; k++)
- {
- for (int l = endkol; l >= startkol; l--)
- {
- if (k == red && l == kol)
- {
- continue;
- }
- checkedbit = (newboard[k] & (1 << l)) == 0 ? 0 : 1;
- if (checkedbit == 1)
- {
- countones++;
- }
- }
- }
- if (currentbit == 1)
- {
- if (countones < 2 || 3 < countones)
- {
- oldboard[red] &= ~(1 << kol);
- }
- }
- else
- {
- if (countones == 3)
- {
- oldboard[red] |= (1 << kol);
- }
- }
- }
- }
- foreach (var row in oldboard)
- {
- Console.WriteLine(Convert.ToString(row, 2).PadLeft(10, '0'));
- }
- //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