結果
問題 | No.345 最小チワワ問題 |
ユーザー | nc_research |
提出日時 | 2021-10-04 18:24:10 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,409 bytes |
コンパイル時間 | 5,010 ms |
コンパイル使用メモリ | 80,052 KB |
実行使用メモリ | 58,704 KB |
最終ジャッジ日時 | 2023-09-30 00:55:34 |
合計ジャッジ時間 | 10,447 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 122 ms
55,480 KB |
testcase_01 | AC | 121 ms
55,840 KB |
testcase_02 | AC | 121 ms
56,076 KB |
testcase_03 | AC | 118 ms
55,752 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 120 ms
55,800 KB |
testcase_08 | AC | 120 ms
55,676 KB |
testcase_09 | AC | 121 ms
55,648 KB |
testcase_10 | AC | 121 ms
55,844 KB |
testcase_11 | AC | 120 ms
55,948 KB |
testcase_12 | AC | 123 ms
55,720 KB |
testcase_13 | AC | 120 ms
55,948 KB |
testcase_14 | WA | - |
testcase_15 | AC | 120 ms
55,692 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | AC | 121 ms
56,012 KB |
testcase_20 | AC | 121 ms
55,640 KB |
testcase_21 | AC | 118 ms
55,796 KB |
testcase_22 | AC | 124 ms
55,612 KB |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | AC | 123 ms
55,924 KB |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | AC | 118 ms
55,704 KB |
ソースコード
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.*?w.*?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; } }