結果

問題 No.1005 BOT対策
ユーザー ks2m
提出日時 2020-03-06 22:54:53
言語 Java
(openjdk 23)
結果
RE  
実行時間 -
コード長 698 bytes
コンパイル時間 2,155 ms
コンパイル使用メモリ 74,368 KB
実行使用メモリ 54,372 KB
最終ジャッジ日時 2024-10-14 10:50:19
合計ジャッジ時間 6,945 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 3
other AC * 9 RE * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		char[] t = sc.next().toCharArray();
		sc.close();

		if (t.length == 1) {
			for (int i = 0; i < s.length; i++) {
				if (s[i] == t[0]) {
					System.out.println(-1);
					return;
				}
			}
			System.out.println(0);
			return;
		}

		int ans = 0;
		int j = 0;
		for (int i = 0; i <= s.length; i++) {
			if (s[i] == t[j]) {
				if (j == t.length - 1) {
					ans++;
					j = 0;
					if (s[i] == t[j]) {
						j++;
					}
				} else {
					j++;
				}
			} else {
				j = 0;
			}
		}
		System.out.println(ans);
	}
}
0