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:
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):
        if A[i][j:j+m]==B[0]:
            for k in range(1,m):
                if A[i+k][j:j+m]==B[k]:
                    ans='Yes'
                    if k==m-1:
                        break
                else:
                    ans='No'
                    break

print(ans)

Submission status: Wrong Answer

Solution code:
from functools import reduce
import math

def main():
    # N! を求める
    # f = math.factorial(N)
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N,M = (int(_) for _ in input().split())
    A =[]
    B =[]
    for i in range(N):
        A.append(list(_ for _ in input()))
    for i in range(M):
        B.append(list(_ for _ in input()))

    for i in range(N-M+1):
        for j in range(N-M+1):
            # check
            flag = True
            for k in range(M):
                for l in range(M):
                    if A[i+k][j+l] != B[k][l]:
                        flag = False
                        break
            if(flag):
                ans = 'Yes'
                break
            else:
                ans = 'No'


    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from functools import reduce
import math

def main():
    # N! を求める
    # f = math.factorial(N)
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N,M = (int(_) for _ in input().split())
    A =[]
    B =[]
    for i in range(N):
        A.append(list(_ for _ in input()))
    for i in range(M):
        B.append(list(_ for _ in input()))

    for i in range(N-M+1):
        for j in range(N-M+1):
            # check
            flag = True
            for k in range(M):
                for l in range(M):
                    if A[i+k][j+l] != B[k][l]:
                        flag = False
                        break
    if(flag):
        print('Yes')
    else:
        print('No')
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(N - M + 1):
    for j in range(N - M + 1):
        flg = 1
        for x in range(M):
            for y in range(M):
                if B[x][y] !=  A[i+x][j+y]:
                    flg = 0
            if flg == 1:
                print('Yes')
                sys.exit()
print('No')

Submission status: Wrong Answer

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

for i in range(N - M + 1):
    for j in range(N - M + 1):
        flg = 1
        for x in range(M):
            for y in range(M):
                if B[x][y] !=  A[i+x][j+y]:
                    flg = 0
            if flg == 1:
                break
print('Yes') if flg == 1 else print('No')

Submission status: Wrong Answer

Solution code:
t,*a=open(0);n,m=map(int,t.split());r=range(n-m+1);print('YNeos'[all(a[n:-1]!=[t[j:j+m]for t in a[i:i+m]]for i in r for j in r)::2])

Submission status: Wrong Answer

Solution code:
t,*a=open(0);n,m=map(int,t.split());r=range(n-m+1);print('YNeos'[all(a[n:]!=[t[j:j+m]for t in a[i:i+m]]for i in r for j in r)::2])

Submission status: Wrong Answer

Solution code:

import sys
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()))


#
print(a)
print(b)
  
  
for i in range(n-m+1):
  for j in range(n-m+1):
    flag = True
    for x in range(m):
      for y in range(m):
        if b[x][y] !=  a[i+x][j+y]:
          flag = False
          break
        if not flag:
          break
    else:
      print("Yes")
      sys.exit()
     
    

print("No")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n,m = map(int,input().split())
a = [0] * n
b = [0] * m
for i in range(n):
    a[i] = list(input())
for i in range(m):
    b[i] = list(input())

ans = False

for i in range(n-m):
    for j in range(n-m):
        match = 0
        for k in range(m):
            for l in range(m):
                if a[k+i][l+j] == b[k][l]:
                    match += 1
        if match == m * m:
            ans = True

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

Submission status: Wrong Answer

Solution code:
def INSTR():
	return input()

def INNUM():
	return int(INSTR())

def INSTR_S():
	return INSTR().split()

def INNUM_S():
	return map(int, INSTR_S())

def INSTR_M(n):
	return [INSTR() for _ in range(n)]

def INNUM_SM(n):
	return [tuple(INNUM_S()) for _ in range(n)]

N, M = INNUM_S()
NPIC = INSTR_M(N)
MPIC = INSTR_M(M)

for i, npic in enumerate(NPIC[:-M+1]):
	if MPIC[0] in npic:
		c = npic.find(MPIC[0])
		for j, mpic in enumerate(MPIC):
			if c != NPIC[i + j].find(mpic):
				break
		else:
			print("Yes")
			exit()
print("No")

Submission status: Wrong Answer

Solution code:
def INSTR():
	return input()

def INNUM():
	return int(INSTR())

def INSTR_S():
	return INSTR().split()

def INNUM_S():
	return map(int, INSTR_S())

def INSTR_M(n):
	return [INSTR() for _ in range(n)]

def INNUM_SM(n):
	return [tuple(INNUM_S()) for _ in range(n)]

N, M = INNUM_S()
NPIC = INSTR_M(N)
MPIC = INSTR_M(M)

for i, npic in enumerate(NPIC[:-M+1]):
	if MPIC[0] in npic:
		c = npic.find(MPIC[0])
		for j, mpic in enumerate(MPIC):
			if c != NPIC[i + j].find(mpic):
				break
		else:
			print("Yes")
			break
else:
	print("No")

Submission status: Wrong Answer

Solution code:
def INSTR():
	return input()

def INNUM():
	return int(INSTR())

def INSTR_S():
	return INSTR().split()

def INNUM_S():
	return map(int, INSTR_S())

def INSTR_M(n):
	return [INSTR() for _ in range(n)]

def INNUM_SM(n):
	return [tuple(INNUM_S()) for _ in range(n)]

N, M = INNUM_S()
NPIC = INSTR_M(N)
MPIC = INSTR_M(M)

for i, npic in enumerate(NPIC):
	if MPIC[0] in npic:
		c = npic.find(MPIC[0])
		for j, mpic in enumerate(MPIC):
			if c != NPIC[i + j].find(mpic):
				print("No")
				exit()
		print("Yes")
		exit()
print("No")
exit()

Submission status: Wrong Answer

Solution code:
from sys import exit
n, m = map(int, input().split())
s1 = " ".join([input() for _ in range(n)])
s2 = [input() for _ in range(m)]
flag = True

i = 0
while i < m:
    try:
        if s1.count(s2[i]) == 0:
            print("No")
            exit()
        ind = s1.index(s2[i])
        s1 = list(s1)
        del s1[ind]
        s1 = "".join(s1)
        if s1[ind+n+1:ind+n+m+1:] == s2[i+1]:
            i += 1
    except:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

n,m = map(int,input().split())
a = [i for i in range(n+1)]
b = [i for i in range(m+1)]
for i in range(1,n+1):
    a[i] = list(input())
for i in range(1,m+1):
    b[i] = list(input())
ans = True

for x in range(1,len(a[1])-len(b[1]) + 1 + 1):
    for y in range(1,len(a)-len(b) + 1 + 1):
        for ax in range(1,m+1):
            for ay in range(m):
                if a[ax][ay] != b[ax][ay]:
                    ans = False
                    break
            else:
                ans = True

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

n,m = map(int,input().split())
a = [i for i in range(n+1)]
b = [i for i in range(m+1)]
for i in range(1,n+1):
    a[i] = list(input())
for i in range(1,m+1):
    b[i] = list(input())
ans = True

for x in range(1,len(a[1])-len(b[1]) + 1 + 1):
    for y in range(1,len(a)-len(b) + 1 + 1):
        for ax in range(1,m+1):
            for ay in range(m):
                if a[ax][ay] != b[ax][ay]:
                    ans = False
                    break
            else:
                ans = True

print(ans)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
pic=[list(input()) for _ in range(N)]
temp=[list(input()) for __ in range(M)]
flag=0
for i in range(N-M+1):
    if flag==0:
        for j in range(N-M+1):
            if all(pic[x+j][i:i+M+1]==temp[x] for x in range(M)):
                print("Yes")
                flag=1
                break
if flag==0:print("No")

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
pic=[list(input()) for _ in range(N)]
temp=[list(input()) for __ in range(M)]
flag=0
for i in range(N-M+1):
    for j in range(N-M+1):
        if all(pic[x+j][i:i+M+1]==temp[x] for x in range(M)):
            print("Yes")
            flag=1
if flag==0:print("No")

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
pic=[list(input()) for _ in range(N)]
temp=[list(input()) for __ in range(M)]
flag=0
for i in range(M):
    for j in range(N-M+1):
        if all(pic[x+j][i:i+M+1]==temp[x] for x in range(M)):
            print("Yes")
            flag=1
if flag==0:print("No")

Submission status: Wrong Answer

Solution code:
import sys
N,M=map(int,input().split())
pic=[list(input()) for _ in range(N)]
temp=[list(input()) for __ in range(M)]
flag=0
for i in range(M):
    for j in range(N-M+1):
        if all(pic[x+j][i:i+M+1]==temp[x] for x in range(M)):
            print("Yes")
            sys.exit()
print("No")

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
pic=[list(input()) for _ in range(N)]
temp=[list(input()) for __ in range(M)]
for i in range(M):
    for j in range(N-M+1):
        if all(pic[x+j][i:i+M+1]==temp[x] for x in range(M)):
            print("Yes")

Submission status: Wrong Answer

Solution code:
N, M = list(map(int, input().split()))

A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

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

print("No")

Submission status: Wrong Answer

Solution code:
N, M = list(map(int, input().split()))

A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

result = True
for i in range(N - M + 1):
    for j in range(N - M + 1):
        for x in range(M):
            for y in range(M):
                s1 = A[i+x][j+y]
                s2 = B[x][y]
                if s1 != s2:
                    result = False
                    break
        if result is False:
            break

if result is True:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N, M = list(map(int, input().split()))

A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

result = True
for i in range(N - M + 1):
    for j in range(N - M + 1):
        for x in range(M):
            for y in range(M):
                s1 = A[i+x][j+y]
                s2 = B[x][y]
                if s1 != s2:
                    result = False
                    break
            if result is False:
                break

if result is True:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N, M = list(map(int, input().split()))

A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

# 画像Bを平行移動させる回数
# (N − M + 1) × (N − M + 1) 通り
for i in range(N - M + 1):
    for j in range(N - M + 1):
        for k in range(M):
            s1 = A[i + k][j : j + M]
            s2 = B[k]
            if s1 != s2:
                break
        else:
            print("Yes")

print("No")

Submission status: Wrong Answer

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

flag = False

for a in A:
    if not flag and B[0] in a:
        flag = True
        idx = 1
    elif flag and B[idx] in a:
        idx += 1
        if idx == M:
            ans = 'Yes'
            break
    else:
        flag = False
print(ans)

Submission status: Wrong Answer

Solution code:
N,M =map(int,input().split())
A=[[str(j) for j in input().split()] for i in range(N)]
B=[[str(j) for j in input().split()] for i in range(M)]
A_s=0
counter=0
for i,b in enumerate(B):
    for j,a in enumerate(A):
        if b[0] in a[0] and A_s==0 :
            counter+=1
        elif A_s !=0 and A_s ==j-1 and b[0] in a[0]:
            A_s =j
            counter+=1
            
if counter>0 and counter%len(B)==0:
    print('Yes')
else:
	print('No')

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split());a,b,ans=[input()for i in range(n)],[input()for i in range(m)],"No"
for i in range(n-m+1):
  for j in range(n-m+1):
    c=[(a[i])[j:j+m]for k in range(m)]
    if b==c:ans="Yes"
print(ans)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
As = []
Bs = []
check = False
for n in range(N):
    As.append(input())
for m in range(M):
    Bs.append(input())
for i in range(len(As)-len(Bs)):
    minicheck = True
    for j in range(len(Bs)):
        if Bs[j] not in As[i+j]:
            minicheck = False
            break
    if minicheck == True:
        check = True
        break
if check == True:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
As = []
Bs = []
check = False
for n in range(N):
    As.append(input())
for m in range(M):
    Bs.append(input())
for i in range(len(As)-len(Bs)):
    minicheck = True
    for j in range(len(Bs)):
        if Bs[j] not in As[i]:
            minicheck = False
            break
    if minicheck == True:
        check = True
        break
if check == True:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
la=[]
lb=[]
b=True
c=True
for i in range(n):
  la.append(list(input()))
for i in range(m):
  lb.append(list(input()))
for j in range(0,n-m+1):
  for i in range(0,n-m):
    c=True
    for r in range(0,m):
      if la[i+r][j:j+m]==lb[r][0:m] and c==True:
        b=True
      else:
        b=False
        c=False
  if b==True:
    break
if b==True:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
la=[]
lb=[]
b=True
c=True
for i in range(n):
  la.append(list(input()))
for i in range(m):
  lb.append(list(input()))
for j in range(0,n-m):
  for i in range(0,n-m):
    c=True
    for r in range(m):
      if la[i+r][j:j+m]==lb[r][0:m] and c==True:
        b=True
      else:
        b=False
        c=False
  if b==True:
    break
if b==True:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
m,n=map(int,input().split())
la=[]
lb=[]
b=True
for i in range(n):
  la.append(list(input()))
for i in range(m):
  lb.append(list(input()))
for j in range(0,n-m):
  for i in range(0,n-m):
    for r in range(m):
      if la[i+r][j:j+m]==lb[r][0:m]:
        b=True
      else:
        b=False
  if b==True:
    break
if b==True:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
m,n=map(int,input().split())
la=[]
lb=[]
b=True
for i in range(n):
  la.append(list(input()))
for i in range(m):
  lb.append(list(input()))
for j in range(0,n-m+1):
  for i in range(0,n-m+1):
    for r in range(m):
      if la[i+r][j:j+m]==lb[r][0:m]:
        b=True
      else:
        b=False
  if b==True:
    break
if b==True:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

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

ans = "No"

for i in range(N-M+1):
    for j in range(N-M+1):
        t = [k[j:j+M] for k in A[i:i+M]]
    if t == B:
        ans = "Yes"
 
print(ans)

Submission status: Wrong Answer

Solution code:
m,n=map(int,input().split())
la=[]
lb=[]
b=True
for i in range(n):
  la.append(list(input()))
for i in range(m):
  lb.append(list(input()))
for i in range(0,n-m+1):
  for j in range(0,n-m+1):
    for r in range(m):
      if la[i+r][j:j+m]==lb[r][0:m]:
        b=True
      else:
        b=False
  if b==True:
    break
if b==True:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
a = []
b = []
# flg = False
# success = False
n, m = map(int, input().split())
count = 0
for i in range(n):
    a.append(input())
for r in range(m):
    b.append(input())

for t in range(n - m+1):
    # if success:
    #     break
    for s in range(n -m +1):
    # cycle 2
        if a[t][s:m] == b[0]:
            # if t+m > n:
            #     continue
            tmp = 1
            for y in range(1, m):
                 # if not flg:
                #     break
                # for x in range(s, s + m):
                if a[t + y][s:m] == b[y]:
                    # flg = False
                    tmp += 1
                else: break
            count = max(count, tmp)

if count == m:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a = []
b = []
# flg = False
# success = False
n, m = map(int, input().split())
count = 0
for i in range(n):
    a.append(input())
for r in range(m):
    b.append(input())

for t in range(n - m+1):
    # if success:
    #     break
    for s in range(n -m +1):
    # cycle 2
        if a[t][s:m] == b[0]:
            # if t+m > n:
            #     continue
            tmp = 1
            for y in range(1, m):
                 # if not flg:
                #     break
                # for x in range(s, s + m):
                if a[t + y][s:m] == b[y]:
                    # flg = False
                    tmp += 1
                else: break
            count = max(count, tmp)

if count >= m:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a = []
b = []
# flg = False
# success = False
n, m = map(int, input().split())
count = 0
for i in range(n):
    a.append(input())
for r in range(m):
    b.append(input())

for t in range(n - m+1):
    # if success:
    #     break
    for s in range(n -m +1):
    # cycle 2
        if a[t][s:m] == b[0]:
            # if t+m > n:
            #     continue
            tmp = 1
            for y in range(1, m):
                 # if not flg:
                #     break
                # for x in range(s, s + m):
                if a[t + y][s:m] == b[y]:
                    # flg = False
                    tmp += 1
            count = max(count, tmp)

if count >= m:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a = []
b = []
# flg = False
# success = False
n, m = map(int, input().split())
count = 0
for i in range(n):
    a.append(input())
for r in range(m):
    b.append(input())

for t in range(n - m+1):
    # if success:
    #     break
    for s in range(n -m +1):
    # cycle 2
        if a[t][s:m] == b[0]:
            # if t+m > n:
            #     continue
            tmp = 0
            for y in range(m):
                 # if not flg:
                #     break
                # for x in range(s, s + m):
                if a[t + y][s:m] == b[y]:
                    # flg = False
                    tmp += 1
            count = max(count, tmp)

if count >= m:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a = []
b = []
# flg = False
# success = False
n, m = map(int, input().split())
count = 0
for i in range(n):
    a.append(input())
for r in range(m):
    b.append(input())

for t in range(n - m+1):
    # if success:
    #     break
    for s in range(n - +1):
    # cycle 2
        if a[t][s:m] == b[0]:
            # if t+m > n:
            #     continue
            tmp = 0
            for y in range(m):
                 # if not flg:
                #     break
                # for x in range(s, s + m):
                if a[t + y][s:m] == b[y]:
                    # flg = False
                    tmp += 1
            count = max(count, tmp)

if count >= m:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a = []
b = []
# flg = False
# success = False
n, m = map(int, input().split())
count = 0
for i in range(n):
    a.append(input())
for r in range(m):
    b.append(input())

for t in range(n - m+1):
    # if success:
    #     break
    for s in range(n - m):
    # cycle 2
        if a[t][s:m] == b[0]:
            # if t+m > n:
            #     continue
            tmp = 0
            for y in range(m):
                 # if not flg:
                #     break
                # for x in range(s, s + m):
                if a[t + y][s:m] == b[y]:
                    # flg = False
                    tmp += 1
            count = max(count, tmp)

if count >= m:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a = []
b = []
# flg = False
# success = False
n, m = map(int, input().split())
count = 0
for i in range(n):
    a.append(input())
for r in range(m):
    b.append(input())

for t in range(n - m):
    # if success:
    #     break
    for s in range(n - m):
    # cycle 2
        if a[t][s:m] == b[0]:
            # if t+m > n:
            #     continue
            tmp = 0
            for y in range(m):
                 # if not flg:
                #     break
                # for x in range(s, s + m):
                if a[t + y][s:m] == b[y]:
                    # flg = False
                    tmp += 1
            count = max(count, tmp)

if count >= m:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a = []
b = []
# flg = False
# success = False
n, m = map(int, input().split())
count = 0
for i in range(n):
    a.append(input())
for r in range(m):
    b.append(input())

for t in range(n - m):
    # if success:
    #     break
    for s in range(n - m):
    # cycle 2
        if a[t][s:m] == b[0]:
            if t+m > n:
                continue
            tmp = 0
            for y in range(m):
                 # if not flg:
                #     break
                # for x in range(s, s + m):
                if a[t + y][s:m] == b[y]:
                    # flg = False
                    tmp += 1
            count = max(count, tmp)

if count >= m:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a = []
b = []
# flg = False
# success = False
n, m = map(int, input().split())
count = 0
for i in range(n):
    a.append(input())
for r in range(m):
    b.append(input())

for t in range(n - m):
    # if success:
    #     break
    for s in range(n - m):
    # cycle 2
        if a[t][s:m] == b[0]:
            if t+m-1 > n:
                continue
            tmp = 0
            for y in range(m):
                 # if not flg:
                #     break
                # for x in range(s, s + m):
                if a[t + y][s:m] == b[y]:
                    # flg = False
                    tmp += 1
            count = max(count, tmp)

if count >= m:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a = []
b = []
# flg = False
# success = False
n, m = map(int, input().split())
count = 0
for i in range(n):
    a.append(input())
for r in range(m):
    b.append(input())

for t in range(n - m+1):
    # if success:
    #     break
    for s in range(n - m+1):
    # cycle 2
        if a[t][s:m] == b[0]:
            if t+m > n:
                continue
            tmp = 0
            for y in range(m):
                 # if not flg:
                #     break
                # for x in range(s, s + m):
                if a[t + y][s:m] == b[y]:
                    # flg = False
                    tmp += 1
            count = max(count, tmp)

if count >= m:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a = []
b = []
# flg = False
# success = False
n, m = map(int, input().split())
count = 0
for i in range(n):
    a.append(input())
for r in range(m):
    b.append(input())

for t in range(n - m+1):
    # if success:
    #     break
    for s in range(n - m+1):
    # cycle 2
        if a[t][s:m] == b[0]:
            if t+m > n-1:
                continue
            tmp = 0
            for y in range(m):
                 # if not flg:
                #     break
                # for x in range(s, s + m):
                if a[t + y][s:m] == b[y]:
                    # flg = False
                    tmp += 1
            count = max(count, tmp)

if count >= m:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a = []
b = []
# flg = False
# success = False
n, m = map(int, input().split())
count = 0
for i in range(n):
    a.append(input())
for r in range(m):
    b.append(input())

for t in range(n - m+1):
    # if success:
    #     break
    for s in range(n - m+1):
    # cycle 2
        if a[t][s:m] == b[0]:
            if t+m+1 > n:
                continue
            tmp = 0
            for y in range(m):
                 # if not flg:
                #     break
                # for x in range(s, s + m):
                if a[t + y][s:m] == b[y]:
                    # flg = False
                    tmp += 1
            count = max(count, tmp)

if count >= m:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a = []
b = []
flg = False
success = False
n, m = map(int, input().split())
count = 0
for i in range(n):
    a.append(input())
for r in range(m):
    b.append(input())

for t in range(n - m+1):
    if success:
        break
    for s in range(n - m+1):
    # cycle 2
        if a[t][s:m] == b[0]:
            if t+m > n:
                continue
            tmp = 0
            for y in range(m):
                 # if not flg:
                #     break
                # for x in range(s, s + m):
                if a[t + y][s:m] == b[y]:
                    # flg = False
                    tmp += 1
            count = max(count, tmp)

if count >= m:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a = []
b = []
flg = False
success = False
n, m = map(int, input().split())
count = 0
for i in range(n):
    a.append(input())
for r in range(m):
    b.append(input())

for t in range(n - m+1):
    if success:
        break
    for s in range(n - m+1):
    # cycle 2
        if a[t][s:m] == b[0]:
            if t+m >= n:
                continue
            tmp = 0
            for y in range(m):
                 # if not flg:
                #     break
                # for x in range(s, s + m):
                if a[t + y][s:m] == b[y]:
                    # flg = False
                    tmp += 1
            count = max(count, tmp)

if count >= m:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a = []
b = []
flg = False
success = False
n, m = map(int, input().split())
count = 0
for i in range(n):
    a.append(input())
for r in range(m):
    b.append(input())

for t in range(n - m+1):
    if success:
        break
    for s in range(n - m+1):
    # cycle 2
        if a[t][s:m] == b[0]:
            if t+m >= n:
                continue
            for y in range(m):
                tmp = 0
                # if not flg:
                #     break
                # for x in range(s, s + m):
                if a[t + y][s:m] == b[y]:
                    # flg = False
                    tmp += 1
            count = max(count, tmp)

if count >= m:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a = []
b = []
flg = False
success = False
n, m = map(int, input().split())
count = 0
for i in range(n):
    a.append(input())
for r in range(m):
    b.append(input())

for t in range(n - m+1):
    if success:
        break
    for s in range(n - m+1):
    # cycle 2
        if a[t][s:m] == b[0]:
                if t+m >= n:
                    continue
                for y in range(m):
                    # if not flg:
                    #     break
                    # for x in range(s, s + m):
                        if a[t + y][s:m] == b[y]:
                            # flg = False
                            count += 1

if count == m:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
a = []
b = []
flg = False
success = False
n, m = map(int, input().split())
for i in range(0, n):
    a.append(input())
for r in range(0, m):
    b.append(input())

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split(' '))
A=[input() for x in range(N)]
B=[input() for x in range(M)]
ans = 'No'
for h in range(0,(N-M)+1):
  for w in range(0,(N-M)+1):
    if sum([B[i]!=A[i+h][w:(w+M+1)] for i in range(M)])==0:
      ans = 'Yes'
print(ans)