Surveillance | 프로그래밍의 벗 PivotOJ
PivotOJ

Surveillance

시간 제한: 2000ms메모리 제한: 1024MB출처: Programmeringsolympiaden 2016 — katt3BOJ 21353

문제

A crime has been committed in the city of <insert name here>! All of the donuts in the bakery next to the police station has mysteriously disappeared. Since this is the favourite bakery of the police, every resource available will be used to find the thief.

The police has made a list of suspected donut thieves, but there is no evidence against anyone yet. Luckily, there is security footage from the scene of the crime. Unfortunately it takes way too long time to watch all of the footage to be done before the expiry date of the donuts has passed.

Therefore, you have been tasked with writing a program to find the cookie thieves in the images. Your program will be given a W×WW \times W image of a suspected cookie thief, and a B×BB \times B image from the security footage. An image consists of a rectangular array of pixels, which we represent as integers.

Your program should count the number of occurances of the cookie thief image inside the security footage image. We say that a W×WW \times W subrectangle of the security footage contains the cookie thief image if there exists some constant CC such that every pixel in the subrectangle equals the corresponding pixel in the cookie thief image plus CC. This is because the images may have been taken using different exposure settings, meaning one of the images can be lighter than the other.

입력

The sample judge reads input in the following format:

  • line 11: B W
  • line i=2i = 2 to 2+B12 + B - 1: B[i][0] B[i][1] ... B[i][B - 1]
  • line i=2+Bi = 2 + B to 2+B+W12 + B + W - 1: W[i][0] W[i][1] ... W[i][B - 1]

출력

The judge writes a single line containing the return value of surveillance(B, W, S, T).

예제

예제 1

입력
4 2
1 2 3 4
1 2 3 4
4 3 3 4
4 3 3 4
0 1
0 1
출력
5
코드를 제출하려면 로그인하세요.