結果

問題 No.1005 BOT対策
ユーザー ks2mks2m
提出日時 2020-03-06 22:52:15
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 697 bytes
コンパイル時間 2,457 ms
コンパイル使用メモリ 74,992 KB
実行使用メモリ 41,824 KB
最終ジャッジ日時 2024-04-22 11:31:34
合計ジャッジ時間 7,450 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
41,408 KB
testcase_01 AC 132 ms
41,504 KB
testcase_02 AC 133 ms
41,456 KB
testcase_03 AC 134 ms
41,148 KB
testcase_04 AC 136 ms
41,096 KB
testcase_05 AC 134 ms
41,124 KB
testcase_06 AC 138 ms
41,312 KB
testcase_07 AC 133 ms
41,124 KB
testcase_08 AC 136 ms
41,364 KB
testcase_09 AC 132 ms
41,324 KB
testcase_10 AC 136 ms
41,384 KB
testcase_11 WA -
testcase_12 AC 134 ms
41,020 KB
testcase_13 WA -
testcase_14 AC 135 ms
41,360 KB
testcase_15 AC 136 ms
41,456 KB
testcase_16 WA -
testcase_17 AC 141 ms
41,444 KB
testcase_18 AC 137 ms
41,176 KB
testcase_19 AC 139 ms
41,384 KB
testcase_20 AC 135 ms
41,428 KB
testcase_21 AC 137 ms
41,292 KB
testcase_22 AC 137 ms
41,128 KB
testcase_23 AC 137 ms
41,152 KB
testcase_24 AC 138 ms
41,192 KB
testcase_25 AC 136 ms
41,280 KB
testcase_26 WA -
testcase_27 AC 135 ms
41,824 KB
testcase_28 AC 137 ms
41,224 KB
testcase_29 AC 132 ms
41,164 KB
権限があれば一括ダウンロードができます

ソースコード

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