Submission #1381558


Source Code Expand

import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> num = new ArrayList<Integer>();
		ArrayList<String> param = new ArrayList<String>();
		int system = 0; // 文字の空白区切り 0:ON 1:OFF

		while (sc.hasNext()) {
			if (sc.hasNextInt()) {
				num.add(sc.nextInt());
			} else {
				if (system == 0)
					param.add(sc.next());
				if (system == 1)
					param.add(sc.nextLine());
			}
		}
		Method(num, param);
	}

	static void Method(ArrayList<Integer> num, ArrayList<String> param) {
		int[] n = new int[100];
		for(int i = 0; i <num.size(); i++){
			n[i] = num.get(i);
		}
		String[] p = new String[100];
		for(int i = 0; i <param.size(); i++){
			p[i] = param.get(i);
		}
		////////////////////////////////////////////////////////////////////
		int point = -1;
		boolean flag = false;
		
		for(int i = 0; i <= n[0] - n[1]; i++){
			//System.out.println(p[n[0]] + " " + p[i]);
			point = p[i].indexOf(p[n[0]],point+1);
			//System.out.println(point);
			if(point == -1) continue;
			if(n[1] == 1){
				flag = true;
				break;
			}
			for(int k = 1; k < n[1]; k++){
				//System.out.println((p[i + k]) + " " + p[n[0] + k]);
				if(point != (p[i + k]).indexOf(p[n[0] + k],point)) break;
				//System.out.println(point);
				if(k == n[1]-1) flag = true;
			}
		}
		if(flag){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
	}
}

Submission Info

Submission Time
Task B - Template Matching
User unirita153
Language Java8 (OpenJDK 1.8.0)
Score 200
Code Size 1562 Byte
Status AC
Exec Time 119 ms
Memory 22228 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 2
AC × 10
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All sample_01.txt, sample_02.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt
Case Name Status Exec Time Memory
sample_01.txt AC 96 ms 18644 KB
sample_02.txt AC 95 ms 21844 KB
subtask_1_01.txt AC 95 ms 20820 KB
subtask_1_02.txt AC 96 ms 21844 KB
subtask_1_03.txt AC 108 ms 18900 KB
subtask_1_04.txt AC 101 ms 17492 KB
subtask_1_05.txt AC 104 ms 19924 KB
subtask_1_06.txt AC 119 ms 22228 KB
subtask_1_07.txt AC 115 ms 21588 KB
subtask_1_08.txt AC 106 ms 19540 KB