[AtCoder]ABC054 B- Template Matching

【問題】

B - Template Matching
AtCoder is a programming contest site for anyone from beginners to experts. We hold weekly programming contests online.
問題キャプチャ

【方針】総当りでも大したことはない。

【提出コード】

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

#output
answer = "No"
for i in range(n-m+1):
    for j in range(n-m+1):
        c = [item[i:i+m] for item in a][j:j+m]
        if c == b:
            answer = "Yes"
print(answer)

【提出結果】

Submission #26365482 - AtCoder Beginner Contest 054
AtCoder is a programming contest site for anyone from beginners to experts. We hold weekly programming contests online.

コメント

タイトルとURLをコピーしました