Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Program
- {
- static void Main()
- {
- short[] num = new short[8];
- for (int i = 0; i < 8; i++)
- {
- num[i] = short.Parse(Console.ReadLine());
- }
- short[] score = new short[9]; // store how many times a length occurs
- int length = 0;
- int max = 0;
- int topMax = 0;
- // count 1's sequence for rows
- for (int i = 0; i < 8; i++)
- {
- max = 0;
- length = 0;
- for (int j = 7; j >= 0; j--)
- {
- int bit = (num[i] >> j) & 1;
- if (bit == 1)
- {
- length++;
- if (max < length)
- {
- max = length;
- }
- }
- else
- {
- length = 0;
- }
- }
- score[max]++;
- if (topMax < max)
- {
- topMax = max;
- }
- }
- // count 1's sequence for columns
- for (int i = 0; i < 8; i++)
- {
- max = 0;
- length = 0;
- for (int j = 7; j >= 0; j--)
- {
- int bit = (num[j] >> i) & 1;
- if (bit == 1)
- {
- length++;
- if (max <= length)
- {
- max = length;
- }
- }
- else
- {
- length = 0;
- }
- }
- score[max]++;
- if (topMax <= max)
- {
- topMax = max;
- }
- }
- if (topMax == 1)
- {
- score[topMax] = 1;
- }
- // print results
- Console.WriteLine(topMax);
- Console.WriteLine(score[topMax]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement