結果

問題 No.345 最小チワワ問題
ユーザー nc_researchnc_research
提出日時 2021-10-04 18:07:46
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,413 bytes
コンパイル時間 5,343 ms
コンパイル使用メモリ 80,920 KB
実行使用メモリ 57,944 KB
最終ジャッジ日時 2023-09-30 00:37:40
合計ジャッジ時間 10,743 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,568 KB
testcase_01 AC 123 ms
55,740 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 122 ms
55,740 KB
testcase_05 AC 121 ms
55,708 KB
testcase_06 WA -
testcase_07 AC 120 ms
55,620 KB
testcase_08 AC 119 ms
55,896 KB
testcase_09 AC 122 ms
55,836 KB
testcase_10 AC 122 ms
56,096 KB
testcase_11 AC 122 ms
55,928 KB
testcase_12 AC 122 ms
55,640 KB
testcase_13 AC 122 ms
53,900 KB
testcase_14 AC 121 ms
53,744 KB
testcase_15 AC 121 ms
56,108 KB
testcase_16 AC 123 ms
56,068 KB
testcase_17 WA -
testcase_18 AC 121 ms
55,880 KB
testcase_19 AC 123 ms
55,756 KB
testcase_20 AC 122 ms
55,928 KB
testcase_21 AC 121 ms
55,864 KB
testcase_22 AC 124 ms
55,688 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 122 ms
56,332 KB
testcase_29 AC 120 ms
56,280 KB
testcase_30 WA -
testcase_31 AC 121 ms
55,740 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package com.mycompany.app;

import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.HashMap;
import java.util.regex.Pattern;
import java.util.regex.Matcher;

public class App 
{
    // strをseparatorで分割してArrayList<Integer>へ変換
    public static ArrayList<Integer> splitToArrayList(String str, String separator){
        ArrayList<Integer> ans = new ArrayList<Integer>();
        String[] separated_str = str.split(" ");
        for(int i = 0; i < separated_str.length; i++){
            ans.add(Integer.valueOf(separated_str[i]));
        }
        return ans;
    }

    public static void main( String[] args )
    {
        Scanner scan = new Scanner(System.in);
        String first_line = scan.nextLine();
        scan.close();

        // c, w, wがこの順で現れる正規表現
        Pattern p = Pattern.compile("(c[^c]*w[^c]*w)");
        Matcher m = p.matcher(first_line);

        // 文字列の最大値は100なので,デフォルト値は101
        int min_length = 101;
        while(m.find()){
            int matching_str_length = m.group().length();
            if(matching_str_length < min_length){
                min_length = matching_str_length;
            }
        }
        if(min_length == 101) System.out.println(-1);
        else System.out.println(min_length);
        return;

    }

}
0