結果

問題 No.1005 BOT対策
ユーザー ks2mks2m
提出日時 2020-03-06 22:54:53
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 698 bytes
コンパイル時間 2,240 ms
コンパイル使用メモリ 77,660 KB
実行使用メモリ 41,756 KB
最終ジャッジ日時 2024-04-22 11:31:45
合計ジャッジ時間 7,087 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 AC 121 ms
40,944 KB
testcase_05 RE -
testcase_06 AC 128 ms
41,268 KB
testcase_07 AC 124 ms
41,204 KB
testcase_08 AC 128 ms
41,216 KB
testcase_09 AC 124 ms
41,132 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 AC 128 ms
41,412 KB
testcase_19 AC 130 ms
41,184 KB
testcase_20 AC 129 ms
41,164 KB
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 AC 114 ms
39,792 KB
testcase_28 RE -
testcase_29 RE -
権限があれば一括ダウンロードができます

ソースコード

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