結果

問題 No.1005 BOT対策
ユーザー 37zigen37zigen
提出日時 2020-03-06 22:11:58
言語 Java21
(openjdk 21)
結果
AC  
実行時間 138 ms / 2,000 ms
コード長 698 bytes
コンパイル時間 2,560 ms
コンパイル使用メモリ 76,276 KB
実行使用メモリ 41,664 KB
最終ジャッジ日時 2024-04-22 11:24:39
合計ジャッジ時間 7,092 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
41,124 KB
testcase_01 AC 127 ms
41,492 KB
testcase_02 AC 127 ms
41,160 KB
testcase_03 AC 131 ms
41,400 KB
testcase_04 AC 128 ms
41,012 KB
testcase_05 AC 134 ms
41,664 KB
testcase_06 AC 131 ms
41,460 KB
testcase_07 AC 130 ms
41,312 KB
testcase_08 AC 130 ms
41,364 KB
testcase_09 AC 130 ms
41,444 KB
testcase_10 AC 132 ms
41,364 KB
testcase_11 AC 134 ms
41,480 KB
testcase_12 AC 132 ms
41,352 KB
testcase_13 AC 133 ms
41,112 KB
testcase_14 AC 131 ms
41,212 KB
testcase_15 AC 132 ms
41,056 KB
testcase_16 AC 133 ms
41,544 KB
testcase_17 AC 132 ms
41,520 KB
testcase_18 AC 131 ms
41,548 KB
testcase_19 AC 132 ms
41,512 KB
testcase_20 AC 130 ms
41,308 KB
testcase_21 AC 138 ms
41,416 KB
testcase_22 AC 132 ms
41,312 KB
testcase_23 AC 136 ms
41,460 KB
testcase_24 AC 134 ms
41,132 KB
testcase_25 AC 135 ms
41,396 KB
testcase_26 AC 131 ms
41,520 KB
testcase_27 AC 130 ms
41,364 KB
testcase_28 AC 131 ms
41,304 KB
testcase_29 AC 128 ms
41,116 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		new Main().run();
	}
	
	void run() {
		Scanner sc=new Scanner(System.in);
		String S=sc.next();
		String T=sc.next();
		int ans=0;
		for(int i=0;i<S.length();){
			if(i+T.length()<=S.length()&&S.substring(i,i+T.length()).equals(T)){
				if(T.length()==1){
					System.out.println(-1);
					return;
				}
				i=i+T.length()-1;
				++ans;
				continue;
			}
			++i;
		}
		System.out.println(ans);
	}
	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
	
}
0