結果
問題 | No.1005 BOT対策 |
ユーザー |
|
提出日時 | 2020-03-06 22:11:58 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 122 ms / 2,000 ms |
コード長 | 698 bytes |
コンパイル時間 | 2,421 ms |
コンパイル使用メモリ | 86,752 KB |
実行使用メモリ | 46,604 KB |
最終ジャッジ日時 | 2025-06-20 00:48:49 |
合計ジャッジ時間 | 6,875 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
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)); } }