結果
問題 | No.1005 BOT対策 |
ユーザー |
![]() |
提出日時 | 2020-03-06 22:52:15 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 697 bytes |
コンパイル時間 | 2,218 ms |
コンパイル使用メモリ | 74,700 KB |
実行使用メモリ | 54,372 KB |
最終ジャッジ日時 | 2024-10-14 10:50:09 |
合計ジャッジ時間 | 6,551 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 WA * 4 |
ソースコード
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);}}