/******************************************************* * Copyright (C) 2015 Haotian Wu * * This file is the solution to the question: * https://www.hackerrank.com/challenges/the-grid-search * * Redistribution and use in source and binary forms are permitted. *******************************************************/ #include #include #include #include #include #include #include #include #include using namespace std; // Naive approach seems to have O(RCrc) complexity in worst case... int main() { char ori[1001][1001]; char pattern[1001][1001]; int tt; int R, C, r, c; scanf("%d",&tt); while (tt--) { scanf("%d %d",&R,&C); for (int i=0;i=R) break; for (int j=0;j=C) break; int flag=1; for (int k=0;k