結果
| 問題 | No.345 最小チワワ問題 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-07-28 11:59:08 |
| 言語 | PHP (8.5.4) |
| 結果 |
AC
|
| 実行時間 | 34 ms / 2,000 ms |
| コード長 | 481 bytes |
| 記録 | |
| コンパイル時間 | 1,510 ms |
| コンパイル使用メモリ | 35,888 KB |
| 実行使用メモリ | 36,928 KB |
| 最終ジャッジ日時 | 2026-04-12 16:36:49 |
| 合計ジャッジ時間 | 3,655 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
コンパイルメッセージ
No syntax errors detected in Main.php
ソースコード
<?php
$str = trim(fgets(STDIN));
$len = strlen($str);
$exists = preg_match_all("/c.*?w.*?w/", $str, $matches);
$min = PHP_INT_MAX;
if($exists) {
foreach($matches[0] as $match) {
$min = min($min, strlen($match));
}
for($i = 0; $i < $len-2; $i++) {
$exists = preg_match("/c.*?w.*?w/", substr($str, $i), $matches);
if($exists) {
$min = min($min, strlen($matches[0]));
}
}
echo $min;
} else {
echo -1;
}
echo PHP_EOL;