시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 256 MB 4 3 3 75.000%

문제

Photography is a deceptively simple subject to the naïve outsider.

In truth, viewing angles, saturation levels, contrast, proper lighting and focusing all play a part. Today, we are most concerned with the problem of focus. 

The proudest space telescope of all, Inquisition IV, launched into space over a decade ago and is starting to show its age in the pictures sent back. Not only is the resolution low by modern standards, all images are painfully blurry! Each pixel in the camera viewport is reported as the average of all those around it in an N ×N box, rounded downwards into an integer.

To secure more funding for future research (and, if budget allows it, some lens wipes for the next telescope) you need to prove you know what’s out there, specifically the number of stellar bodies visible to the telescope. As is well-known by now, stellar bodies are very bright: in fact it is guaranteed that each registers as a region of horizontally and vertically connected pixels of total brightness to the sensor, while everything else registers as fully black.

Handily the telescope has framed the entire “scene”, including capturing all of the surrounding blurriness on camera. This means that any pixels outside the capture region can also be considered as totally black.

입력

  • One line containing three integers N, R and C (1 ≤ N ≤ 99 ≤ R, C ≤ 1000; N ≡ 1 mod 2) indicating the blur box width and rows and columns registered by the camera respectively.
  • Another R lines, each containing C space-separated hexadecimal integers Lr,c (0x0000 ≤ Lr,c ≤ 0xFFFF) where a value of 0x0000 is total blackness and a value of 0xFFFF is total whiteness.

출력

A single integer: the number of stellar bodies visible in the snapshot.

예제 입력

1 5 6
0000 FFFF 0000 0000 0000 0000
FFFF FFFF 0000 FFFF FFFF 0000
0000 0000 0000 FFFF 0000 0000
0000 FFFF FFFF FFFF FFFF 0000
0000 0000 0000 0000 0000 0000

예제 출력

2

예제 입력 2

3 5 6
1C71 1C71 1C71 0000 0000 0000
1C71 1C71 1C71 0000 0000 0000
1C71 1C71 1C71 1C71 1C71 1C71
0000 0000 0000 1C71 1C71 1C71
0000 0000 0000 1C71 1C71 1C71

예제 출력 2

2

힌트