結果
問題 |
No.345 最小チワワ問題
|
ユーザー |
![]() |
提出日時 | 2024-10-16 15:47:33 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 686 bytes |
コンパイル時間 | 2,271 ms |
コンパイル使用メモリ | 75,604 KB |
実行使用メモリ | 56,080 KB |
最終ジャッジ日時 | 2024-10-16 15:47:41 |
合計ジャッジ時間 | 7,997 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 15 WA * 14 |
ソースコード
import java.util.*; import java.util.regex.*; public class Main { public static void main(String[] args) throws Exception { var sc = new Scanner(System.in); String line = sc.next(); var pattern = Pattern.compile("c.*?w.*?w"); var matcher = pattern.matcher(line); int min = Integer.MAX_VALUE; while(matcher.find()){ //System.out.println(matcher.group()); min = Math.min(min, matcher.group().length()); } if(min == Integer.MAX_VALUE){ System.out.println(-1); }else{ System.out.println(min); } } }