Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package javaapplication5;
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.util.ArrayList;
- /**
- *
- * @author HoangLong
- */
- public class JavaApplication5 {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) throws IOException {
- // 自分の得意な言語で
- // Let's チャレンジ!!
- String line, line2;
- int n, m;
- int i, j;
- ArrayList<ArrayList<Integer>> arrayN = new ArrayList<>();
- ArrayList<ArrayList<Integer>> arrayM = new ArrayList<>();
- BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
- line = br.readLine();
- n = Integer.parseInt(line);
- for (i = 0; i < n; i++) {
- line = br.readLine();
- line2 = line.replaceAll("\\s+", "");
- arrayN.add(new ArrayList<>());
- for (j = 0; j < n; j++) {
- arrayN.get(i).add(Character.getNumericValue(line2.charAt(j)));
- }
- }
- line = br.readLine();
- m = Integer.parseInt(line);
- for (i = 0; i < m; i++) {
- line = br.readLine();
- line2 = line.replaceAll("\\s+", "");
- arrayM.add(new ArrayList<>());
- for (j = 0; j < m; j++) {
- arrayM.get(i).add(Character.getNumericValue(line2.charAt(j)));
- }
- }
- int resultV = 0;
- int resultH = 0;
- result_found:
- for (resultV = 0; resultV <= n - m; resultV++) {
- for (resultH = 0; resultH <= n - m; resultH++) {
- wrong_result:
- for (i = 0; i < m; i++) {
- for (j = 0; j < m; j++) {
- if (arrayN.get(resultV + i).get(resultH + j) != arrayM.get(i).get(j)) {
- break wrong_result;
- }
- if (i == m - 1 && j == m - 1) {
- break result_found;
- }
- }
- }
- }
- }
- System.out.println(resultV + " " + resultH);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement