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 i in range(n)]
b = [input() for j in range(m)]
ans = "No"
for i in range(n-m+1):
    for j in range(n-m+1):
        count = 0
        for k in range(m):
            for l in range(m):
                if b[k][l] == a[i+k][j+l]:
                    count += 1
        if count == m*m:
            ans = "Yes"
            break
    else:
      pass
    break
print(ans)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
A=['.' for _ in range(N)]
B=['.' for _ in range(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+1):
    for j in range(N-M+1):
        tmp=True
        for k in range(M):
            for l in range(M):
                if A[i+k][j+l]!=B[k][l]:
                    tmp=False
            if tmp==True:
                Ans=True
if Ans==True:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys

n,m=map(int,input().split())
ln=[list(input()) for i in range(n)]
lm=[list(input()) for i in range(m)]

flg=0
for i in range(n-m+1):
  for j in range(n-m+1):
    if ln[i][j:j+m]==lm[0][0:]:
      flg=1
      for k in range(m-1):
        if ln[i+k+1][j:j+m]!=lm[k+1][0:]:
          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 _ in range(n)]
b = [input() for _ in range(m)]
for i in range(n - m):
    for j in range(n - m):
        flag = True
        for k in range(m):
            if a[k + j][i:i + m] != b[k]:
                flag = False
                break
        if flag:
            print("Yes")
            exit()
print("No")

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=[]
b=[]
for i in range(n):
    aa=list(input())
    a.append(aa)
for i in range(m):
    bb=list(input())
    b.append(bb)
f=False
count=0
for i in range(n-m+1):
    for l in range(n-m+1):
        for j in range(m):
            for k in range(m):
                if b[j][k]==a[j+i][k+l]:
                    count*=1
                else:
                    count*=0
        if count==1:
            f=True
        count=1
if f:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=[]
b=[]
for i in range(n):
    aa=list(input())
    a.append(aa)
for i in range(m):
    bb=list(input())
    b.append(bb)
f=False
count=0
for i in range(n-m+1):
    for l in range(n-m+1):
        for j in range(m):
            for k in range(m):
                print(a[j+i][k+l])
                if b[j][k]==a[j+i][k+l]:
                    count*=1
                else:
                    count*=0
        if count==1:
            f=True
        count=1
if f:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=[]
b=[]
for i in range(n):
    aa=list(input())
    a.append(aa)
for i in range(m):
    bb=list(input())
    b.append(bb)
f=False
count=0
for i in range(n-m+1):
    for j in range(m):
        for k in range(m):
            if b[j][k]==a[j+i][k+i]:
                count*=1
            else:
                count*=0
    if count==1:
        f=True
    count=1
if f:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
A = [input() for i in range(N)]
B = [input() for j in range(M)]
ans = "No"
for i in range(N-M+1):
    for j in range(N-M+1):
        count = 0
        for k in range(M):
            for l in range(M):
                if B[k][l] == A[i+k][i+l]:
                    count += 1
        if count == M*M:
            ans = "Yes"
            break
    else:
        continue
    break
print(ans)

Submission status: Wrong Answer

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


for i in range(n-m):
    for j in range(n-m):
        flag = 0
        for k in range(m):
            for l in range(m):
                if a[i + k][j + l] != b[k][l]:
                    flag = 1
        if flag == 0:
            print('Yes')
            exit()


print('No')

Submission status: Wrong Answer

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


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

print('No')

Submission status: Wrong Answer

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


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

print('No')

Submission status: Wrong Answer

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


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

print('No')

Submission status: Wrong Answer

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

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 B[k][l]!=A[i+k][j+l]:
                    flag=False
                    break
            if flag==False:
                break
        if flag:
            break
if flag:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
def isSame(h, w):
    for i in range(h, h+m):
        for j in range(w, w+m):
            # print(i, j)
            if A[i][j] != B[i-h][j-w]:
                return False
    return True


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

for i in range(0, n-m):
    for j in range(0, n-m):
        if isSame(i, j) is True:
            print("Yes")
            exit()
print("No")

Submission status: Wrong Answer

Solution code:
int_n, int_m = map(int, input().split())

li_a = list()
li_b = list()

for i in range(int_n):
    li_a.append(input())

for i in range(int_m):
    li_b.append(input())


for x in range(int_n - int_m):
    for y in range(int_n - int_m):
        li_w = [a[0 + x: int_m + x] for a in li_a[0 + y: int_m + y]]

        if "".join(li_w) == "".join(li_b):
            print("Yes")
            exit(0)
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
L=[]
S=[]
for i in range(N):
    x = input()
    l=[y for y in x]
    L.append(l)
for i in range(M):
    x = input()
    s=[y for y in x]
    S.append(s)
flag = 0
sum = 0
for i in range(N):
    for j in range(N):
        for k in range(M):
            for l in range(M):
                if i+k < N and j+l < N:
                    if L[i+k][j+l] == S[k][l]:
                        sum += 1
                        if sum == M * M:
                            flag = 1
                    else:
                        sum = 0
if flag == 0:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
L=[]
S=[]
for i in range(N):
    x = input()
    l=[y for y in x]
    L.append(l)
for i in range(M):
    x = input()
    s=[y for y in x]
    S.append(s)
flag = 0
sum = 0
for i in range(N):
    for j in range(N):
        for k in range(M):
            for l in range(M):
                if i+k < N and j+l < N:
                    if L[i+k][j+l] == S[k][l]:
                        sum += 1
                        if sum == N * N:
                            flag = 1
                    else:
                        sum = 0
if flag == 0:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
L=[]
S=[]
for i in range(N):
    x = input()
    l=[y for y in x]
    L.append(l)
for i in range(M):
    x = input()
    s=[y for y in x]
    S.append(s)
flag = 0
for i in range(N):
    for j in range(N):
        for k in range(M):
            for l in range(M):
                if i+k < N and j+l < N:
                    if L[i+k][j+l] == S[k][l]:
                        flag = 1
                        break
if flag == 0:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = [input() for i in range(N)]
B = [input() for j in range(M)]
flag = 0
f = True
b = 1
for i in range(len(A)-len(B)+1):
    if A[i].find(B[0]) != -1:
        c = i
        flag += 1
        start = A[c].find(B[0])
        if len(B) == 1:
            break
        else:
            for j in range(1, len(B)):
                if A[c+1][start:start+len(B[0])+1] == B[b]:
                    b += 1
                    c += 1
                    flag += 1
                    if len(B)-j == 1 and f is True:
                        print('Yes')
                        f = False
                else:
                    flag = 0
                    break
if flag == len(B) and f is True:
    print('Yes')
elif flag != len(B) and f is True:
    print('No')

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = [input() for i in range(N)]
B = [input() for j in range(M)]
flag = 0
f = True
for i in range(len(A)-len(B)+1):
    if A[i].find(B[0]) != -1:
        c = i
        flag += 1
        if len(B) == 1:
            break
        else:
            for j in range(1, len(B)):
                if A[c+1].find(B[j]) == A[c].find(B[0]):
                    c += 1
                    flag += 1
                    if len(B)-j == 1 and f is True:
                        print('Yes')
                        f = False
                else:
                    flag = 0
                    break
if flag == len(B) and f is True:
    print('Yes')
elif flag != len(B) and f is True:
    print('No')

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = [input() for i in range(N)]
B = [input() for j in range(M)]
flag = 0
f = True
for i in range(len(A)-len(B)+1):
    if A[i].find(B[0]) != -1:
        c = i
        flag += 1
        if len(B) == 1:
            break
        else:
            for j in range(1, len(B)):
                if A[c+1].find(B[j]) == A[c].find(B[0]):
                    c += 1
                    flag += 1
                    if len(B)-j == 1 and f == True:
                        print('Yes')
                        f = False
                else:
                    break
if flag == len(B) and f == True:
    print('Yes')
elif flag != len(B) and f == True:
    print('No')

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = [input() for i in range(N)]
B = [input() for j in range(M)]
flag = 0
for i in range(len(A)-len(B)+1):
    if A[i].find(B[0]) != -1:
        c = i
        flag += 1
        if len(B) == 1:
            break
        else:
            for j in range(1, len(B)):
                if A[c+1].find(B[j]) == A[c].find(B[0]):
                    c += 1
                    flag += 1
                else:
                    break
if flag == len(B):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = [input() for i in range(N)]
B = [input() for j in range(M)]
flag = 0
for i in range(len(A)-len(B)):
    if A[i].find(B[0]) != -1:
        c = i
        flag += 1
        for j in range(1, len(B)):
            if A[c+1].find(B[j]) == A[c].find(B[0]):
                c += 1
                flag += 1
            else:
                break
if flag == len(B):
    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)]

cnt = 0
for a in A:
  for b in B:
    if(cnt != M):
      if(b in a):
        cnt += 1
    else:
      break
if(cnt == M):
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=[input() for i in range(n)]
b=[input() for j in range(m)]
res = 'No'
for k in range(len(a[0])):
    for l in range(len(b[0])):
        if list(map(lambda o:o[l:l+m],a[k:k+m]))==b:
                    res = 'Yes'
print(res)

Submission status: Wrong Answer

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

for i in range(n):
  k=i+m
  for j in range(n):
    if k <= n:
      if A[i][j:k]== B[0]:
        o=0
        for l in range(i,i+m):
          if A[l][j:k]!=B[o]:
            break
          else:
            o+=1
        if o==m:
          print('Yes')
          exit()
print('No')

Submission status: Wrong Answer

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

for i in range(n):
  k=i+m
  for j in range(n):
    if k <= n:
      if A[i][j:k]== B[0]:
        for l in range(i,i+m):
          o=0
          if A[l][j:k]!=B[o]:
            continue
          o+=1
        print('Yes')
        exit()
print('No')

Submission status: Wrong Answer

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

for i in range(n):
  for j in range(n):
    k=i+m
    if i+k <= n and i<m:
      if A[i][j:k]== B[i]and i+1<=m:
        for l in range(i+1,m):
          if A[l][j:k]==B[l]:
            print('Yes')
            exit()
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)]

all_segment = []
for width in range(N - M + 1):
    for height in range(N - M + 1):
        segment = [width_list[width: width + N] for width_list in A_list[height: height + M]]
        all_segment.append(segment)

if B_list in all_segment:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
m,n = [int(x) for x in input().split()]
a = []
b = []
for _ in range(m):
  a.append(int(input().replace('#','1').replace('.','2')))
m = 0
for i in range(n):
  b.append(int(input().replace('#','1').replace('.','2')))
  if a[i] == b[i]:
    m += 1
print('Yes') if m == n else print('No')

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N, M = map(int, input().split())
A = "".join([input() for _ in range(N)])
B = "".join([input() for _ in range(M)])

ans = "No"
w = ""
for i in range(0, len(A)+1, N):
    # print(i)
    for j in range(N-M+1):
        w += A[i+j:i+j+M]
        if w == B:
            ans = "Yes"
            break
print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N, M = map(int, input().split())
A = "".join([input() for _ in range(N)])
B = "".join([input() for _ in range(M)])

ans = "No"
w = ""
for i in range(0, len(A), N):
    # print(i)
    for j in range(N-M+1):
        w += A[i+j:i+j+M]
        if w == B:
            ans = "Yes"
            break
print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N, M = map(int, input().split())
A = "".join([input() for _ in range(N)])
B = "".join([input() for _ in range(M)])

ans = "No"
w = ""
for i in range(0, len(A), N):
    # print(i)
    for j in range(N-M):
        w += A[i+j:i+j+M]
        if w == B:
            ans = "Yes"
            break
print(ans)

Submission status: Wrong Answer

Solution code:
# https://beta.atcoder.jp/contests/abc054/tasks/abc054_b


def solve():
    n, m = map(int, input().split())
    img = []
    tmp = []

    for _ in range(n):
        img.append(input())

    for _ in range(m):
        tmp.append(input())

    loops = n - m + 1
    for loop in range(loops):
        for row in range(loops):
            match = True
            for col in range(m):
                if img[col+loop][0][row:row+m] != tmp[col][0]:
                    match = False
            if match:
                print('Yes')
                return
    print('No')


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
# https://beta.atcoder.jp/contests/abc054/tasks/abc054_b


def solve():
    n, m = map(int, input().split())
    img = []
    tmp = []

    for _ in range(n):
        img.append(list(map(str, input().split())))

    for _ in range(m):
        tmp.append(list(map(str, input().split())))

    # never matches found D:
    if n < m:
        print('No')

    loops = n - m + 1
    for loop in range(loops):
        for row in range(loops):
            match = True
            for col in range(m):
                match = img[col+loop][0][row:row+m] != tmp[col][0]
            if match:
                print('Yes')
                return
    print('No')


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-


"""
https://beta.atcoder.jp/contests/abc054/tasks/abc54_1
"""

import sys
import math
from inspect import currentframe

def debug_print(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args), file=sys.stderr)

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


delta = N - M
match = False

for dx in range(delta):
    for dy in range(delta):
        window = [pixels[dx:dx+M] for pixels in A[dy:dy+M]]
        if window == B:
            match = True
            break

if match:
    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)]

for i in range(n-m+1):
    for j in range(n-m+1):
        if a[i][j] == b[0][0]:
            flag = 0
            for u in range(m):
                for v in range(m):
                    if a[i+u][j+v] != b[u][v]:
                        flag = -1
                        break
                if flag == -1:
                    break
            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):
        if a[i][j] == b[0][0]:
            flag = 0
            for u in range(m):
                for v in range(m):
                    if a[i+u][j+v] != b[u][v]:
                        flag = -1
                        break
                if flag == -1:
                    break
                else:
                    print('Yes')
                    exit()
print('No')

Submission status: Wrong Answer

Solution code:
tn = []
tm = []

def check(d):
    for h in range(d + 1):
        for w in range(d + 1):
            mw = len(tm)
            for tmh in range(mw):
                if tn[h][w:w + mw] == tm[tmh]:
                    return True

    return False

N, M = list(map(int, input().rstrip().split()))
for i in range(N):
    tn.append(list(input().rstrip()))

for i in range(M):
    tm.append(list(input().rstrip()))

w = N - M

print('Yes' if check(w) else 'No')

Submission status: Wrong Answer

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

def check(i):
    # from (i, i) to (i+M, i+M)
    ret = True
    for h in range(M):
        for w in range(M):
            if A[h+i][w+i] != B[h][w]:
                ret = False

    return ret
                
if N == M:
    print("Yes" if check(0) else "No")
    sys.exit()
    
for i in range(N-M):
    if check(i):
        print("Yes")
        break
else:
    print("No")

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)]

def check(i):
    # from (i, i) to (i+M, i+M)
    ret = True
    for h in range(M):
        for w in range(M):
            if A[h+i][w+i] != B[h][w]:
                ret = False

    return ret
                

for i in range(N-M+1):
    if check(i):
        print("Yes")
        break
else:
    print("No")

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)]

def check(i):
    # from (i, i) to (i+M, i+M)
    for h in range(M):
        ret = True
        for w in range(M):
            if A[h+i][w+i] != B[h][w]:
                ret = False
        if ret:
            return True
    return False
                

for i in range(N-M+1):
    if check(i):
        print("Yes")
        break
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = [input() for i in range(N)]
B = [input() for i in range(M)]
i = 0
while(i <= N - M):
    x = A[i].find(B[0])
    while(N - M >= x >= 0):
        for j in range(1,M):
            if A[i+j][x-1:x-1+M] != B[j]:
                x = A[i].find(B[0], x+1)
                break
        else:
            print("Yes")
            exit()
    i += 1
print("No")

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = [input() for i in range(N)]
B = [input() for i in range(M)]
i = 0
while(i < N - M):
    x = A[i].find(B[0])
    while(x >= 0):
        for j in range(1,M):
            if x != A[i+j].find(B[j]):
                x = A[i].find(B[0], x)
                break
        else:
            print("Yes")
            exit()
    i += 1
print("No")

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
A = [input() for i in range(N)]
B = [input() for i in range(M)]
dxy = []
for y in range(M) :
    for x in range(M) :
        dxy.append((x,y))
flag = 0
for y in range(N) :
    for x in range(N) :
        if A[y][x] == B[0][0] and flag == 0 :
            counter = 0
            for dx,dy in dxy :
                if flag == 0 :
                    nx = x+dx
                    ny = y+dy
                    if not (0 <= nx <= N-1) :
                        continue
                    if not (0 <= ny <= N-1) :
                        continue
                    if A[ny][nx] != B[ny][nx] :
                        break
                    flag = 1
if flag == 1 :
    print("Yes")
else :
    print("No")

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
A = [input() for i in range(N)]
B = [input() for i in range(M)]
dxy = []
for y in range(M) :
    for x in range(M) :
        dxy.append((x,y))
flag = 0
for y in range(N) :
    for x in range(N) :
        if A[y][x] == B[0][0] and flag == 0 :
            counter = 0
            for dx,dy in dxy :
                if flag == 0 :
                    nx = x+dx
                    ny = y+dy
                    if not (0 <= nx <= N-1) :
                        break
                    if not (0 <= ny <= N-1) :
                        break
                    if A[ny][nx] != B[ny][nx] :
                        break
                    flag = 1
if flag == 1 :
    print("Yes")
else :
    print("No")

Submission status: Wrong Answer

Solution code:
## ABC 054 b
import sys

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

for i in range(n-m):
    for j in range(n-m):
        if (b[::1] == [ai[j:j+m] for ai in a[i:i+m]]):
            print('Yes')
            sys.exit()

print('No')

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
nl = [input() for x in range(n)]
ml = [input() for x in range(m)]
ans = "No"

for i in range(n-m+1):
    ok = True
    if ml[0] in nl[i]:
        for f in range(m):
            if ml[f] not in nl[i + f]:
                ok = False
                break
        if ok:
            ans = "Yes"
print(ans)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
nl = [input() for x in range(n)]
ml = [input() for x in range(m)]
ans = "No"

for i in range(n-m):
    ok = True
    if ml[0] in nl[i]:
        for f in range(m):
            if ml[f] not in nl[i + f]:
                ok = False
                break
        if ok:
            ans = "Yes"
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from sys import stdin

n,m = [int(x) for x in stdin.readline().rstrip().split()]
A = []
for i in range(n):
    s = stdin.readline().rstrip()
    A.append(s)
B = []
for i in range(m):
    s = stdin.readline().rstrip()
    B.append(s)

Submission status: Wrong Answer

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


for x in range(N-M+1):
    for y in range(N-M+1):
        for j in range(M):
            
            if A[y+j][x:x+M] != B[j]:
                break
        ans ='Yes'

print(ans)

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)]
for i in range(N-M+1):
    for j in range(N-M+1):
        ans='Yes'
        for k in range(i,i+M):
            for l in range(j,j+M):
                if A[k][l]!=B[k-i][l-j]:
                    ans='No'
        if ans=='Yes':
            break
print(ans)

Submission status: Wrong Answer

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

for _ in range(n):
    a += [list(input())]
for _ in range(m):
    b += [list(input())]

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

Submission status: Wrong Answer

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

print(a,b)

for i in range(n-m+1):
  for j in range(n-m+1):
    if [k[j:m+1] for k in a[i:m+1]] == b:
      print("Yes")
      exit()
print("No")

Submission status: Wrong Answer

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

print(a,b)

for i in range(n-m+1):
  for j in range(n-m+1):
    if [k[j:m] for k in a[i:m]] == b:
      print("Yes")
      exit()
print("No")

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
a_list = []
b_list = []

for _ in range(n):
    a_list.append(input())

for _ in range(m):
    b_list.append(input())

ans_cnt = 0
for b in b_list:
    for a in a_list:
        if b in a:
            ans_cnt += 1
            break

if ans_cnt == m:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

for i in range(n-m+1):
  for j in range(n-m+1):
    if [k[j:m+1+j] for k in a[i:m+1+i]] == b:
      print("Yes")
      exit()
print("No")

Submission status: Wrong Answer

Solution code:
def input_pattern(cnt):
    temp_list = []

    for _ in range(cnt):
        temp_list.append(input())

    return temp_list
    
def find_pattern(target_list,pattern_list):
    p_len = len(pattern_list)
    cnt = 0

    for t in target_list:
        for p in pattern_list:
            if cnt == p_len:
                return True
            else:
                if p in t:
                    cnt += 1
                    break
                else:
                    cnt = 0

    return False

a,b = map(int,input().split())
a_list = input_pattern(a)
b_list = input_pattern(b)

if find_pattern(a_list,b_list):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
list_a = []
list_b = []
count = 0
while count < n:
    list_a.append(list(str(input())))
    count += 1
count = 0
while count < m:
    list_b.append(list(str(input())))
    count += 1
#print(list_a)
#print(list_b)[
phase = 0
for i in range(0, n-m):
    for j in range(0, n-m):
        for k in range(0,m):
            if list_a[i+k][j:j+m] == list_b[k]:
                if k != m-1:
                    continue
                else:
                    pass
            else:
                break
            phase = 1
            print("Yes")
            break
        if phase == 1:
            break
    if phase == 1:
        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)]

ch = 0
for i in range(N-M+1):
    for j in range(1,M-1):
        cnt = 0
        for k in range(M):
            if B[k] == A[i+k][j:j+M]:
                cnt += 1
        if cnt == M:
            ch = 1
if ch == 1:
    print('Yes')
else:
    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())

for i in range(N-M):
    ind = -1
    while B[0] in A[i][ind+1:]:
        ind = A[i].find(B[0])
        ch = 0
        for j in range(1,M-1):
            if A[i][ind:ind+M+1] == B[j]:
                ch = 0
                continue
            else:
                ch = 1
                break
        if ch == 0:
            print('Yes')
            exit()
print('No')