Submission #62292324


Source Code Expand

Copy
N, M = map(int, input().split())
S = [list(input()) for _ in range(N)]
T = [list(input()) for _ in range(M)]
B = []
for i in range(N):
for j in range(N - M + 1):
if S[i][j:j+M] == T[0]:
B.append((j, i))
for x, iy in B:
if iy + M > N: continue
for oy in range(M):
y = iy + oy
if S[y][x:x+M] != T[oy]:
break
else:
print(iy + 1, x + 1)
exit()
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
N, M = map(int, input().split())
S = [list(input()) for _ in range(N)]
T = [list(input()) for _ in range(M)]

B = []

for i in range(N):
    for j in range(N - M + 1):
        if S[i][j:j+M] == T[0]:
            B.append((j, i))

for x, iy in B:
    if iy + M > N: continue
    for oy in range(M):
        y = iy + oy
        if S[y][x:x+M] != T[oy]:
            break
    else:
        print(iy + 1, x + 1)
        exit()

Submission Info

Submission Time
Task B - Seek Grid
User KNSN92
Language Python (PyPy 3.10-v7.3.12)
Score 200
Code Size 441 Byte
Status AC
Exec Time 63 ms
Memory 81808 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 2
AC × 26
Set Name Test Cases
Sample 00_sample_01.txt, 00_sample_02.txt
All 00_sample_01.txt, 00_sample_02.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 02_handmade_01.txt, 02_handmade_02.txt, 02_handmade_03.txt, 02_handmade_04.txt
Case Name Status Exec Time Memory
00_sample_01.txt AC 59 ms 76824 KB
00_sample_02.txt AC 59 ms 76588 KB
01_random_01.txt AC 59 ms 76516 KB
01_random_02.txt AC 63 ms 80920 KB
01_random_03.txt AC 59 ms 76568 KB
01_random_04.txt AC 59 ms 76476 KB
01_random_05.txt AC 61 ms 76660 KB
01_random_06.txt AC 62 ms 80908 KB
01_random_07.txt AC 59 ms 76488 KB
01_random_08.txt AC 62 ms 81200 KB
01_random_09.txt AC 59 ms 76720 KB
01_random_10.txt AC 62 ms 81324 KB
01_random_11.txt AC 59 ms 76660 KB
01_random_12.txt AC 59 ms 76592 KB
01_random_13.txt AC 59 ms 76520 KB
01_random_14.txt AC 62 ms 81808 KB
01_random_15.txt AC 61 ms 81084 KB
01_random_16.txt AC 62 ms 81296 KB
01_random_17.txt AC 59 ms 76520 KB
01_random_18.txt AC 60 ms 76400 KB
01_random_19.txt AC 62 ms 81016 KB
01_random_20.txt AC 61 ms 80968 KB
02_handmade_01.txt AC 59 ms 76564 KB
02_handmade_02.txt AC 59 ms 76352 KB
02_handmade_03.txt AC 59 ms 76532 KB
02_handmade_04.txt AC 60 ms 76536 KB


2025-04-03 (Thu)
23:24:13 +00:00