#P10474. [ICPC 2011 Beijing R] Matrix 矩阵哈希

[ICPC 2011 Beijing R] Matrix 矩阵哈希

Problem Description

Given an MM-row NN-column 0101 matrix, and QQ 0101 matrices of size AA rows and BB columns, you need to determine which of these QQ matrices appear in the original matrix.

A 0101 matrix means that every element in the matrix is either 00 or 11.

Input Format

The first line of the input file contains M,N,A,BM, N, A, B, as described above.

The next MM lines each contain NN characters, each being either 00 or 11, describing the original matrix.

The next line contains the number of queries QQ.

Then follow QQ matrices, totaling Q×AQ \times A lines, where each line contains BB characters, describing the QQ 0101 matrices.

Output Format

Output QQ lines. Each line should be 00 or 11, indicating whether the corresponding matrix appears in the original matrix: 00 means it does not appear, and 11 means it does.

3 3 2 2
111
000
111
3
11
00
11
11
00
11
1
0
1

Hint

For 100%100\% of the actual testdata, 1M,N10001 \leq M, N \leq 1000, and Q=1000Q = 1000.

For 40%40\% of the testdata, A=1A = 1.

For 80%80\% of the testdata, A10A \leq 10.

For 100%100\% of the testdata, A100A \leq 100.

Translated by ChatGPT 5