Submission #1592133


Source Code Expand

def mask_judge(a, b, i, j):
    flag = 1
    for k in range(m):
        for l in range(m):
            if a[i+k][j+l] != b[k][l]:
                flag = 0
                break
    return flag


def main():
    a = [[0 if i == '.' else 1 for i in input()] for _ in range(n)]
    b = [[0 if i == '.' else 1 for i in input()] for _ in range(m)]

    flag = 0
    for i in range(n-m+1):
        for j in range(n-m+1):
            if mask_judge(a, b, i, j):
                flag = 1
                break
    if flag:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    n, m = map(int, input().split())
    main()

Submission Info

Submission Time
Task B - Template Matching
User gospursgo
Language Python (3.4.3)
Score 200
Code Size 669 Byte
Status AC
Exec Time 27 ms
Memory 3064 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 2
AC × 10
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All sample_01.txt, sample_02.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt
Case Name Status Exec Time Memory
sample_01.txt AC 17 ms 3064 KB
sample_02.txt AC 17 ms 3064 KB
subtask_1_01.txt AC 17 ms 3064 KB
subtask_1_02.txt AC 17 ms 3064 KB
subtask_1_03.txt AC 17 ms 3064 KB
subtask_1_04.txt AC 18 ms 3064 KB
subtask_1_05.txt AC 20 ms 3064 KB
subtask_1_06.txt AC 18 ms 3064 KB
subtask_1_07.txt AC 27 ms 3064 KB
subtask_1_08.txt AC 22 ms 3064 KB