Created
February 3, 2016 12:25
-
-
Save anonymous/6c8ff56ea7cd504b0e8c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.util.Scanner; | |
public class Slipp01{ | |
static int R, C, r, c; | |
static String G[], P[]; | |
public static void main(String args[]){ | |
Scanner in = new Scanner(System.in); | |
int test_case = in.nextInt(); | |
Boolean result = false; | |
for( int test = 0 ; test < test_case ; test ++){ // T | |
result = test(in); | |
if(result){ | |
System.out.println("YES"); | |
}else{ | |
System.out.println("NO"); | |
} | |
} | |
} | |
private static Boolean test(Scanner in){ | |
R = in.nextInt(); | |
C = in.nextInt(); | |
G = new String[R]; | |
for(int G_i=0; G_i < R; G_i++){ | |
G[G_i] = in.next(); | |
} | |
r = in.nextInt(); | |
c = in.nextInt(); | |
P = new String[r]; | |
for(int P_i=0; P_i < r; P_i ++){ | |
P[P_i] = in.next(); | |
} | |
// 여기까지 데이터 입력 완료 | |
for( int i = 0; i <= R-r; i ++ ){ | |
int res = 0; | |
while(true) { | |
res = G[i].indexOf(P[0], res+1); | |
if( res == -1 ) break; | |
if (check(i, res)) | |
return Boolean.TRUE; | |
} | |
} | |
return Boolean.FALSE; | |
} | |
private static Boolean check(int row, int col){ | |
for( int checkRow = 1; checkRow < r; checkRow ++) { | |
int res = G[row + checkRow].indexOf(P[checkRow], col); | |
if (res == col) { | |
continue; | |
} else { | |
return Boolean.FALSE; | |
} | |
} | |
return Boolean.TRUE; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment