結果

問題 No.1005 BOT対策
ユーザー joybeeeejoybeeee
提出日時 2020-05-14 15:46:53
言語 Java21
(openjdk 21)
結果
AC  
実行時間 123 ms / 2,000 ms
コード長 679 bytes
コンパイル時間 1,961 ms
コンパイル使用メモリ 71,084 KB
実行使用メモリ 56,132 KB
最終ジャッジ日時 2023-10-13 11:04:17
合計ジャッジ時間 7,169 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
55,628 KB
testcase_01 AC 119 ms
55,500 KB
testcase_02 AC 119 ms
55,876 KB
testcase_03 AC 123 ms
56,068 KB
testcase_04 AC 119 ms
55,476 KB
testcase_05 AC 123 ms
55,644 KB
testcase_06 AC 122 ms
55,720 KB
testcase_07 AC 120 ms
55,548 KB
testcase_08 AC 121 ms
55,844 KB
testcase_09 AC 120 ms
55,488 KB
testcase_10 AC 122 ms
55,576 KB
testcase_11 AC 123 ms
55,956 KB
testcase_12 AC 122 ms
55,400 KB
testcase_13 AC 122 ms
55,608 KB
testcase_14 AC 123 ms
55,796 KB
testcase_15 AC 122 ms
55,812 KB
testcase_16 AC 122 ms
55,920 KB
testcase_17 AC 123 ms
55,608 KB
testcase_18 AC 122 ms
56,072 KB
testcase_19 AC 121 ms
55,700 KB
testcase_20 AC 121 ms
56,132 KB
testcase_21 AC 122 ms
56,100 KB
testcase_22 AC 123 ms
55,780 KB
testcase_23 AC 123 ms
55,740 KB
testcase_24 AC 123 ms
55,364 KB
testcase_25 AC 121 ms
55,880 KB
testcase_26 AC 121 ms
55,472 KB
testcase_27 AC 121 ms
55,968 KB
testcase_28 AC 121 ms
55,660 KB
testcase_29 AC 117 ms
55,944 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;) {
        if(s.substring(i, i + lenT).equals(t)) {
          cnt++;
          i += lenT - 1;
        } else i++;
      }
      System.out.println(cnt);
  }
}
0