結果

問題 No.1005 BOT対策
ユーザー ks2mks2m
提出日時 2020-03-06 22:50:05
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 581 bytes
コンパイル時間 2,383 ms
コンパイル使用メモリ 74,900 KB
実行使用メモリ 41,568 KB
最終ジャッジ日時 2024-04-22 11:30:17
合計ジャッジ時間 6,909 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 109 ms
40,896 KB
testcase_01 AC 106 ms
39,984 KB
testcase_02 AC 112 ms
40,028 KB
testcase_03 AC 117 ms
41,136 KB
testcase_04 AC 114 ms
41,088 KB
testcase_05 AC 105 ms
39,956 KB
testcase_06 AC 121 ms
40,980 KB
testcase_07 AC 121 ms
41,280 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 115 ms
40,920 KB
testcase_11 WA -
testcase_12 AC 113 ms
40,984 KB
testcase_13 WA -
testcase_14 AC 117 ms
41,328 KB
testcase_15 AC 115 ms
40,740 KB
testcase_16 WA -
testcase_17 AC 117 ms
41,184 KB
testcase_18 WA -
testcase_19 AC 114 ms
41,108 KB
testcase_20 AC 113 ms
41,060 KB
testcase_21 AC 120 ms
41,116 KB
testcase_22 AC 121 ms
40,848 KB
testcase_23 AC 102 ms
39,952 KB
testcase_24 AC 102 ms
40,252 KB
testcase_25 AC 119 ms
41,116 KB
testcase_26 WA -
testcase_27 AC 99 ms
39,348 KB
testcase_28 AC 115 ms
41,088 KB
testcase_29 AC 117 ms
41,240 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) {
			System.out.println(-1);
			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