結果

問題 No.1005 BOT対策
ユーザー joybeeeejoybeeee
提出日時 2020-05-14 15:44:36
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 673 bytes
コンパイル時間 2,725 ms
コンパイル使用メモリ 71,292 KB
実行使用メモリ 58,140 KB
最終ジャッジ日時 2023-10-13 11:01:50
合計ジャッジ時間 7,755 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 113 ms
55,584 KB
testcase_01 AC 116 ms
55,584 KB
testcase_02 AC 119 ms
55,340 KB
testcase_03 AC 118 ms
55,680 KB
testcase_04 AC 114 ms
55,712 KB
testcase_05 AC 118 ms
55,340 KB
testcase_06 AC 120 ms
53,820 KB
testcase_07 AC 120 ms
55,744 KB
testcase_08 AC 115 ms
55,588 KB
testcase_09 AC 112 ms
55,816 KB
testcase_10 AC 117 ms
55,396 KB
testcase_11 AC 116 ms
55,988 KB
testcase_12 WA -
testcase_13 AC 124 ms
55,624 KB
testcase_14 AC 118 ms
56,028 KB
testcase_15 AC 119 ms
55,684 KB
testcase_16 AC 116 ms
55,784 KB
testcase_17 AC 120 ms
55,956 KB
testcase_18 AC 121 ms
55,956 KB
testcase_19 AC 123 ms
56,116 KB
testcase_20 AC 120 ms
58,140 KB
testcase_21 AC 124 ms
55,724 KB
testcase_22 AC 116 ms
55,584 KB
testcase_23 AC 118 ms
56,164 KB
testcase_24 AC 120 ms
55,920 KB
testcase_25 AC 120 ms
55,932 KB
testcase_26 AC 121 ms
56,112 KB
testcase_27 AC 117 ms
55,752 KB
testcase_28 WA -
testcase_29 AC 118 ms
55,912 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      String s = sc.next();
      String t = sc.next();
      
      int lenT = t.length();
      if(lenT == 1) {
          for(char c : s.toCharArray())
            if(c == t.charAt(0)) {
                System.out.println(-1);
                return;
            }
          System.out.println(0);
          return;
      }
      int cnt = 0;
      for(int i = 0; i < s.length() - lenT + 1; i++) {
        if(s.substring(i, i + lenT).equals(t)) {
          cnt++;
          i += lenT - 1;
        }
      }
      System.out.println(cnt);
  }
}
0