We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
intmain(){/* Enter your code here. Read input from STDIN. Print output to STDOUT */intt;cin>>t;while(t--){intr1,c1,r2,c2,flag=0;cin>>r1>>c1;vector<string>s(r1);for(inti=0;i<r1;i++)cin>>s[i];cin>>r2>>c2;vector<string>p(r2);for(inti=0;i<r2;i++)cin>>p[i];for(inti=0;i<=r1-r2;i++){for(intj=0;j<=c1-c2;j++){flag=0;if(s[i][j]==p[0][0]&&s[i].substr(j,c2)==p[0]){intd=i+1,k=1;for(;k<r2;k++){if(s[d++].substr(j,c2)!=p[k]){break;}}if(k==r2){flag=1;break;}}}if(flag==1){break;}}if(flag==1){cout<<"YES\n";}else{cout<<"NO\n";}}return0;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
The Grid Search
You are viewing a single comment's thread. Return to all comments →
My code Passed this TC. :)