結果

問題 No.430 文字列検索
ユーザー devtatuodevtatuo
提出日時 2020-05-05 07:24:36
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,785 ms / 2,000 ms
コード長 1,022 bytes
コンパイル時間 2,300 ms
コンパイル使用メモリ 72,928 KB
実行使用メモリ 53,036 KB
最終ジャッジ日時 2023-09-08 05:35:54
合計ジャッジ時間 12,768 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
49,212 KB
testcase_01 AC 191 ms
52,596 KB
testcase_02 AC 307 ms
52,780 KB
testcase_03 AC 313 ms
52,240 KB
testcase_04 AC 42 ms
49,256 KB
testcase_05 AC 42 ms
49,200 KB
testcase_06 AC 42 ms
49,148 KB
testcase_07 AC 42 ms
49,096 KB
testcase_08 AC 73 ms
51,444 KB
testcase_09 AC 43 ms
49,212 KB
testcase_10 AC 58 ms
50,620 KB
testcase_11 AC 941 ms
52,608 KB
testcase_12 AC 1,219 ms
53,036 KB
testcase_13 AC 1,184 ms
52,244 KB
testcase_14 AC 986 ms
52,836 KB
testcase_15 AC 753 ms
52,560 KB
testcase_16 AC 932 ms
52,500 KB
testcase_17 AC 1,785 ms
52,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

    public static void main(String[] args) throws Exception {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        String s = mylist.get(0);
        int m = Integer.valueOf(mylist.get(1));

        int mysum = 0;
        for (int i = 2; i < 2 + m; i++) {
            String temp = mylist.get(i);
            int sposi = 0;
            while (s.indexOf(temp, sposi) >= 0) {

                sposi = s.indexOf(temp, sposi) + 1;
                mysum += 1;
            }

        }
        System.out.println(mysum);

    }

}
0