Problem:


Score : 200 points

Problem Statement

You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels.

A pixel is the smallest element of an image, and in this problem it is a square of size 1×1.

Also, the given images are binary images, and the color of each pixel is either white or black.  

In the input, every pixel is represented by a character: . corresponds to a white pixel, and # corresponds to a black pixel.

The image A is given as N strings A_1,...,A_N.

The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N).

Similarly, the template image B is given as M strings B_1,...,B_M.

The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M).  

Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images.  

Constraints

1≦M≦N≦50 

A_i is a string of length N consisting of # and ..

B_i is a string of length M consisting of # and ..

Input

The input is given from Standard Input in the following format:

N M
A_1
A_2
:  
A_N
B_1
B_2
:  
B_M

Output

Print Yes if the template image B is contained in the image A. Print No otherwise.

Sample Input 1

3 2
#.#
.#.
#.#
#.
.#

Sample Output 1

Yes

The template image B is identical to the upper-left 2 × 2 subimage and the lower-right 2 × 2 subimage of A. Thus, the output should be Yes.

Sample Input 2

4 1
....
....
....
....
#

Sample Output 2

No

The template image B, composed of a black pixel, is not contained in the image A composed of white pixels.



Sample input:
3 2
#.#
.#.
#.#
#.
.#


Sample output:
Yes

Submission status: Wrong Answer

Solution code:
# 53
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


n, m = LI()
a = SR(n)
b = SR(m)
ans = 'No'
for j in range(n - m + 1):
    is_ok = True
    for bi, i in enumerate(range(m)):
        # print(f'{(bi, i, j)=}')
        # print(f'a: {a[i][j:j+m]} b: {b[bi]}')
        if a[i][j:j+m] != b[bi]:
            is_ok = False
            break
    if is_ok:
        ans = 'Yes'
        break
print(ans)

Submission status: Wrong Answer

Solution code:
# 48
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


n, m = LI()
a = SR(n)
b = SR(m)
ans = 'No'
for j in range(n - m + 1):
    is_ok = True
    for i in range(n - m + 1):
        if a[i][j:j+m] != b[i][j:j+m]:
            is_ok = False
            break
    if is_ok:
        ans = 'Yes'
        break
print(ans)

Submission status: Wrong Answer

Solution code:
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = il()
    A = [iss() for _ in range(N)]
    B = [iss() for _ in range(M)]

    for i in range(N - M + 1):
        for j in range(N - M + 1):
            t = i
            for b in B:
                if t > M: break
                if j + M > N: break
                if A[t][j:j+M] == b:
                    t += 1
                else:
                    break
            else:
                print('Yes')
                exit()
    else:
        print('No')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = il()
    A = [iss() for _ in range(N)]
    B = [iss() for _ in range(M)]

    for i in range(N - M + 1):
        for j in range(N - M + 1):
            t = i
            for b in B:
                # if t > M: break
                if A[t][j:] == b:
                    t += 1
                else:
                    break
            else:
                print('Yes')
                exit()
    else:
        print('No')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = il()
    A = [iss() for _ in range(N)]
    B = [iss() for _ in range(M)]

    for i in range(N):
        for j in range(N - M + 1):
            t = i
            for b in B:
                if t > M: break
                if A[t][j:] == b:
                    t += 1
                else:
                    break
            else:
                print('Yes')
                exit()
    else:
        print('No')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = il()
    A = [iss() for _ in range(N)]
    B = [iss() for _ in range(M)]

    for i in range(N-M+1):
        for j in range(N):
            for b in B:
                if A[i][j:] == b: i += 1
                else:break
            else:
                print('Yes')
                exit()
    else:
        print('No')




if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
ans = 'No'

for i in range(n-m+1):
    for j in range(n-m+1):
        for k in range(m):
            if a[i+k][j:j+m] != b[k]:
                continue
            if k==m-1:
                ans = 'Yes'
                break
                
print(ans)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
ans = 'No'

for i in range(n-m):
    for j in range(n-m):
        for k in range(m):
            if a[i+k][j:j+m] != b[k]:
                continue
            if k==m-1:
                ans = 'Yes'
                break
                
print(ans)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=[input() for _ in range(n)]
b=[input() for _ in range(m)]

for i in range (n-m+1):#行
  g=1
  for j in range(n-m+1):#列
    for k in range(m):#m
     # print(a[i+k][j:j+m],"__",b[k])
      if a[i+k][j:j+m]!=b[k]:
        g*=0
        break
    if g==1:
      print("Yes")
      import sys
      sys.exit()
else:
  print("No")

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
ans = False

for i in range(N-M):
  for j in range(N-M):
    flg = True
    for k in range(M):
      if A[i+k][j:j+M] != B[k]:
        flg = False
    if flg:
      ans = True

if ans:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
ans = 'No'

i = 0
while i < N - M:
  j = 0
  while j < N - M:
    k = 0
    while k < M:
      l = 0
      while l < M:
        if A[i+k][j+l] != B[k][l]:
          l = M+1
          k = M+1
          i += 1
          j += 1
        else:
          l += 1
      k += 1
      if k == M and l == M:
        ans = 'Yes'
        i += N
        j += N
        
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_map = lambda: [s == ord('.') for s in read() if s != ord('\n')]


def main():
    N, M = in_nn()
    t = in_map()
    A = np.array(t[:N * N]).reshape(N, N)
    B = np.array(t[N * N:]).reshape(M, M)

    ans = 'No'
    for i in range(N - M + 1):
        if np.all(A[i:i + M, i:i + M] == B):
            ans = 'Yes'
            break

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=[]
b=[]
for i in range(n):
    a.append(list(input()))
for i in range(m):
    b.append(list(input()))
for i in range(n-m):
    for j in range(n-m):
        flg=True
        for k in range(m):
            for kk in range(m):
                if b[k][kk]!=a[i+k][j+kk]:
                    flg=False
        if flg:
            print("Yes")
            exit()
print("No")

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
alst = [input() for _ in range(n)]
blst = [input() for _ in range(m)]

for i in range(n - m + 1):
    for j in range(n - m + 1):
        for k, row in enumerate(blst):
            if alst[i + k][j:j + m] == blst[k]:
                print("Yes")
                exit()
print("No")

Submission status: Wrong Answer

Solution code:
import sys
N,M = map(int,input().split())
A = [list(map(str,input())) for _ in range(N)]
B = [list(map(str,input())) for _ in range(M)]
#print(A,B)
loc = None
count = [0]*M
#print(A[0][0],B[0][0])
#flag = False
def search(A,B):
    for i in range(M):
        for j in range(N-M):
            if A[j] == B[0]:
                st = j
                refa = j
                refb = 1
                while B[refb] == A[refa+1]:
                    refb+=1
                    refa+=1
                    flag = True
                    if flag == True:
                        return st
    return -1
lst = []
lst2 = []
for i in range(N):
    for j in range(M):
        ref = search(A[i],B[j])
        lst.append(ref)
#if len(set(lst)) == 1:
for i in range(len(lst)):
    if lst[i] != -1:
        lst2.append(lst[i])
        #print(lst[i])
#print(lst2)
#print(set(lst))
if len(set(lst2)) == 1:
    print('Yes')
else:
    print('No')
#print(temp)

Submission status: Wrong Answer

Solution code:
def abc054_b():
    N,M = map(int,input().split())
    a = [input() for i in range(N)]
    b = [input() for i in range(M)]


    ans = 0
    for n in range(M-1):
        for m in range(N-1):
            if b[n] in a[m]:
                ans+=1
    print("Yes" if ans==len(b) else "No")
'''
6 4
#.#
.#.
#.#
#.#
.#.
#.#
#.
.#
#.
.#
'''








abc054_b()

Submission status: Wrong Answer

Solution code:
def abc054_b():
    N,M = map(int,input().split())
    a = [input() for i in range(N)]
    b = [input() for i in range(M)]


    ans = 0
    for n in range(M-1):
        for m in range(N-1):
            print(n,m)
            if b[n] in a[m]:
                ans+=1
    print("Yes" if ans==len(b) else "No")
'''
6 4
#.#
.#.
#.#
#.#
.#.
#.#
#.
.#
#.
.#
'''








abc054_b()

Submission status: Wrong Answer

Solution code:
def abc054_b():
    N,M = map(int,input().split())
    a = [input() for i in range(N)]
    b = [input() for i in range(M)]


    #['#.#', '.#.', '#.#']
    print(a)
    print(b)
    print(N-1)
    print(M-1)
    ans = 0
    for n in range(M-1):
        for m in range(N-1):
            print(n,m)
            if b[n] in a[m]:
                ans+=1
    print("Yes" if ans==len(b) else "No")
'''
6 4
#.#
.#.
#.#
#.#
.#.
#.#
#.
.#
#.
.#
'''








abc054_b()

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]


for i in range(N - M + 1):
    for j in range(N - M + 1):
        check = True
        count = 0
        for k in range(M):
            for p in range(M):
                if (A[i + k][i + p] == B[k][p]):
                    count += 1
                    continue
                else:
                    check = False
                    break

        if (check and count == M * M):
            print('Yes')
            exit()

print('No')

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]


for i in range(N - M + 1):
    for j in range(N - M + 1):
        check = True
        count = 0
        for k in range(M):
            for p in range(M):
                if (A[i + k][i + p] == B[k][p]):
                    count += 1
                    continue
                else:
                    check = False
                    break

            if (check and count == M * M):
                print('Yes')
                exit()
print('No')

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]


for i in range(N - M + 1):
    for j in range(N - M + 1):
        check = True
        for k in range(M):
            for p in range(M):
                if (A[i + k][i + p] == B[k][p]):
                    continue
                else:
                    check = False
                    break

            if (check):
                print('Yes')
                exit()
print('No')

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]


for i in range(N - M + 1):
    for j in range(N - M + 1):
        check = True
        for k in range(M):
            for p in range(M):
                if (A[i + k][i + p] == B[k][p]):
                    continue
                else:
                    check = False
                    break
            if (not check):
                break

            if (check):
                print('Yes')
                exit()
print('No')

Submission status: Wrong Answer

Solution code:
import numpy as np

N,M=map(int, input().split())
A=[]
for i in range(N):
    a=list(input())
    A.append(a)
B=[]
for i in range(M):
    b=list(input())
    B.append(b)

A=np.array(A)
B=np.array(B)
ans="No"
for i in range(N):
    for j in range(N):
        if i+M<N and j+M<N:
            if (A[i:i+M, j:j+M]==B).all():
                ans="Yes"

print(ans)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

for i in range(N-M):
    for j in range(N-M):
        flag = True
        for y in range(M):
            for x in range(M):
                if A[i+y][j+x] != B[y][x]:
                    flag = False
                    break
            if flag == False:
                break
        if flag:
            print("Yes")
            exit()
print("No")

Submission status: Wrong Answer

Solution code:
def readinput():
    n,m=list(map(int,input().split()))
    a=[]
    for _ in range(n):
        a.append(input())
    b=[]
    for _ in range(m):
        b.append(input())
    return n,m,a,b

def main(n,m,a,b):
    for i in range(n-m):
        for j in range(n-m):
            for k in range(m):
                if a[i+k][j:j+m]!=b[k]:
                    break
            else:
                return 'Yes'
    return 'No'

if __name__=='__main__':
    n,m,a,b=readinput()
    ans=main(n,m,a,b)
    print(ans)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
a = []
b = []

for _ in range(N):
    a.append(input())
for _ in range(M):
    b.append(input())
flg = True
for i in range(N-1):
    for j in range(N-M+1):
        #print(a[i][j:j+(M-1)])
        if a[i][j:j+M] == b[0]:
            for k in range(1,M):
                if a[k][j:j+M] != b[k]:
                    flg = False
                    break
            if flg:
                print('Yes')
                exit()
            else:
                flg = True
print('No')

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
A = []
B = []
for i in range(n):
    A.append(input())
for i in range(m):
    B.append(input())

ok = 0
for i in range(n - m + 1):
    for j in range(n - m + 1):
        from_n = [l[i:i+m] for l in A[i:i+m]]
        ok += from_n == B
print('Yes' if ok > 0 else 'No')

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
A = []
B = []
for i in range(n):
    A.append(input())
for i in range(m):
    B.append(input())

ok = True
for i in range(n - m + 1):
    for j in range(n - m + 1):
        from_n = [l[i:i+m] for l in A[i:i+m]]
        ok *= from_n == B
print('Yes' if ok else 'No')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

def II(): return int(input())
def MII(): return map(int, input().split())
def LII(): return list(map(int, input().split()))

def main():
    N, M = MII()
    A = []
    for _ in range(N):
        A.append(list(input()))

    B = []
    for _ in range(M):
        B.append(list(input()))

    f = True
    for i in range(N-M):
        for j in range(N-M):
            for k in range(M):
                if A[i+k][j:j+M] != B[k]:
                    f = False
                    break
                f = True
            if f:
                print('Yes')
                return
    
    print('No')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N,M = I()
maze1 = [list(s()) for _ in range(N)]
maze2 = [list(s()) for _ in range(M)]
L = [[-1]*N for _ in range(N)]
def dfs(x,y):
    if x == N or y == N:
        return
    if x-i == M or y-j == M:
        return
    if maze1[x][y] != maze2[x-i][y-j]:
        L[i][j] = 0
        return
    dfs(x+1,y)
    dfs(x,y+1)
for i in range(M-N):
    for j in range(M-N):
        dfs(i,j)
        if L[i][j] == -1:
            print('Yes')
            exit()
print('No')

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N,M=map(int,input().split())
picN=[]
picM=[]

for i in range(N):
    L=list(input())
    picN.append(L)

for i in range(M):
    L=list(input())
    picM.append(L)

K=N-M

for i in range(K+1):
    for j in range(K+1):
        flg=True
        for a in range(M):
            for b in range(M):
                if picN[a+i][b+j]!=picM[a][b]:
                    flg=False
        if flg:
            break

if flg:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N,M=map(int,input().split())
picN=[]
picM=[]

for i in range(N):
    L=list(input())
    picN.append(L)

for i in range(M):
    L=list(input())
    picM.append(L)

K=N-M
flg=True
for a in range(M):
    for b in range(M):
        if picN[a][b]!=picM[a][b]:
            flg=False

for i in range(K+1):
    for j in range(K+1):
        flg=True
        for a in range(M):
            for b in range(M):
                if picN[a+i][b+j]!=picM[a][b]:
                    flg=False
        if flg:
            break

if flg:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N,M=map(int,input().split())
picN=[]
picM=[]

for i in range(N):
    L=list(input())
    picN.append(L)

for i in range(M):
    L=list(input())
    picM.append(L)

K=N-M
flg=True
for a in range(M):
    for b in range(M):
        if picN[a][b]!=picM[a][b]:
            flg=False

for i in range(K):
    for j in range(K):
        flg=True
        for a in range(M):
            for b in range(M):
                if picN[a+i][b+j]!=picM[a][b]:
                    flg=False
        if flg:
            break
if flg:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
# coding: utf-8

N, M = map(int,input().split())
A = []
B = []
for i in range(N):
    A.append(list(input()))

for i in range(M):
    B.append(list(input()))
    
w = len(B[0])
flg = False    
for i in range(N-M+1):
    if flg:
        break
    
    for j in range(len(A[0])-len(B[0])+1):
        if flg:
            break
        cnt = 0
        for k in range(M):
            #print(i+k)
            if A[k][j:j+w] == B[k]:
                cnt += 1
        if cnt == M:
            flg = True
            break

if flg:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import numpy as np

N,M = map(int,input().split())
A = np.array([list(input()) for _ in range(N)])
B = np.array([list(input()) for _ in range(M)])

bl = False
for i in range(N-M+1):
    for j in range(N-M+1):
        if (A[i:i+M,j:j+M] == B).all():
            bl = True

answer = 'Yes' if bl else 'No'
print(answer)
print(A,B)

Submission status: Wrong Answer

Solution code:
def main():
    n,m = map(int,input().split())
    a,b = [],[]
    for i in range(n):
        a.append(list(input()))
    for j in range(m):
        b.append(list(input()))
    flag = 0
    for i in range(n-m):
        for j in range(n-m):
            counter = 0
            for k in range(m):
                for l in range(m):
                    if a[k+i][l+j] == b[k][l]:
                        counter += 1
            if counter == m**2:
                flag = 1
    print("Yes" if flag else "No")
main()

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = [list(input()) for _ in range(N)]
B = [list(input()) for _ in range(M)]

import numpy as np
A = np.array(A)
B = np.array(B)
# print(A)
# print()
# print(B)
# print()

for i in range(N-M):
    for j in range(N-M):
#         print(i,j)
        a = A[i: i+M, j: j+M]
#         print(a)
#         print()
        if np.all(a == B):
            print('Yes')
            break
    else:
        continue
    break
else:
    print('No')

Submission status: Wrong Answer

Solution code:
def f(s):
    if s==".":
        return 1
    else:
        return 0

N,M=map(int,input().split())
A=[]
for _ in range(N):
    A.append(list(map(f,input())))

B=[]
for _ in range(M):
    B.append(list(map(f,input())))

F=False
for i in range(N-M+1):
    for j in range(N-M+1):
        G=True
        for k in range(M):
            G=G and (A[j+k][i:i+M]==B[k])
    F=F|G
    
if F:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
def f(s):
    if s==".":
        return 1
    else:
        return 0

N,M=map(int,input().split())
A=[]
for _ in range(N):
    A.append(list(map(f,input())))

B=[]
for _ in range(M):
    B.append(list(map(f,input())))

F=False
for i in range(N-M+1):
    for j in range(N-M+1):
        G=True
        for k in range(M):
            G=G and (A[j+k][i:i+M]==B[k])

if G:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a, b = map(int,input().split())
A = [input() for _ in range(a)]
B = [input() for _ in range(b)]

cnt = 0
for i in range(a-b+1):
    for j in range(a-b+1):
        if A[i][j] == B[0][0]:
            for k in range(b):
                for l in range(b):
                    if A[i+k][j+l] == B[k][l]:
                        cnt += 1
        if cnt == b**2:
            break
if cnt == b**2:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = [list(input()) for i in range(N)]
B = [list(input()) for i in range(M)]
ans = False
for i in range(N-M+1):
    for j in range(N-M+1):
        flag = True
        for k in range(M):
            for l in range(M):
                if A[i+k][j+l] == B[k][l]:
                    continue
                flag = False
                break
            if not flag:
                break
        if flag:
            ans = True
        break
    if ans:
        break
if ans:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())

A = [input() for _ in range(n)]
B = [input() for _ in range(m)]

def issubset(l, u, r, d):
    for i, y in enumerate(range(u, d)):
        for j, x in enumerate(range(l, r)):
            res = A[y][x] == B[i][j]
            if not res:
                return False
    return True

for y in range(n - m):
    for x in range(n - m):
        if issubset(x, y, x+m, y+m):
            print("Yes")
            exit()

print("No")

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
s = 0
cnt = 0

for i in range(n-m+1):
    for j in range(n-m+1):
        for x in range(m):
            for y in range(m):
                if a[i+x][j+y] == b[x][y]:
                    s += 1
            if s == m ** 2:
                cnt += 1
            else:
                s = 0
if cnt > 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
l = []
for i in a:
    for j in b:
        if l == b:
            print('Yes')
            exit()
        elif j in i:
            l.append(j)
print('No')

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
cnt = 0
for i in a:
    for j in b:
        if cnt == m:
            print('Yes')
            exit()
        elif j in i:
            cnt += 1
print('No')

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

for i in a:
    for j in b:
        if j in i:
            print('Yes')
            exit()
print('No')

Submission status: Wrong Answer

Solution code:
from itertools import product

n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

for i, j in product(range(n - m + 1), repeat=2):
    print(i,j)
    if all(a[i + k][j:j + m] == b[k] for k in range(m)):
        print('Yes')
        break
else:
    print('No')

Submission status: Wrong Answer

Solution code:
from itertools import product

n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

for i, j in product(range(n - m + 1), repeat=2):
    if all(a[i + k][j:] == b[k] for k in range(m)):
        print('Yes')
        break
else:
    print('No')

Submission status: Wrong Answer

Solution code:
from itertools import product

n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

for i, j in product(range(n - m + 1), repeat=2):
    print(i,j)
    if all(a[i + k][j:] == b[k] for k in range(m)):
        print('Yes')
        break
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

for i, j in zip(range(n - m + 1), range(n - m + 1)):
    if all(a[i + k][j:] == b[k] for k in range(m)):
        print('Yes')
        break
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
s=[input() for i in range(n)]
t=[input() for i in range(m)]

z=0
c=0

for i in range(n-m+1):
    for j in range(n-m+1): 
        
        for x in range(m):
            for y in range(m):
                if s[i+x][j+y]==t[x][y]:
                    z+=1
        if z==m**2:
            c+=1
        else:
            c=0
if c>0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
s=[input() for i in range(n)]
t=[input() for i in range(m)]

z=0
c=0

for i in range(n-m+1):
    for j in range(n-m+1): 
        
        for x in range(m):
            for y in range(m):
                if s[i+x][j+y]==t[x][y]:
                    z+=1
        if z==m**2:
            c+=1
if c>0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
s=[input() for i in range(n)]
t=[input() for i in range(m)]

z=0
c=0

for i in range(n-m+1):
    for j in range(n-m+1):  
        for x in range(m):
            for y in range(m):
                if s[i+x][j+y]==t[x][y]:
                    z+=1
        if z==(n-m+1)**2:
            c+=1
if c>0:
    print('Yes')
else:
    print('No')