Intermedio30 pts
The Grid Search
Traducción al español en progresoEl contenido detallado de esta lección aún se está traduciendo. Mientras tanto, se muestra en inglés.
Given large grid G (R×C) and pattern grid P (r×c), determine if P appears as a contiguous sub-grid in G. Check all possible starting positions. Example: G= 7283455864 6731158619 ... P= 9505 3845 3530 Check if P matches any r×c block in G. Output 'YES' if found, 'NO' otherwise.
Entrada
First line: t (test cases). For each test: first line R C (grid size), next R lines (grid), then r c (pattern size), next r lines (pattern).
Salida
For each test case, output 'YES' if pattern found, 'NO' otherwise.
Ejemplo
2 10 10 7283455864 6731158619 8988242643 3830589324 2229505813 5633845374 6473530293 7053106601 0834282956 4607924137 3 4 9505 3845 3530 15 15 400453592126560 114213133098692 474386082879648 522356951189169 887109450487496 252802633388782 502771484966748 075975207693780 511799789562806 404007454272504 549043809916080 962410809534811 445893523733475 768705303214174 650629270887160 2 2 99 99
Esperado
YES NO
Loading editor…
Resultado
Sin salida aún. Ejecuta tu código para ver resultados.