結果

問題 No.345 最小チワワ問題
コンテスト
ユーザー aya
提出日時 2019-07-31 11:57:49
言語 PHP
(8.5.4)
コンパイル:
php -l _filename_
実行:
php _filename_
結果
AC  
実行時間 30 ms / 2,000 ms
+ 660µs
コード長 354 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 51 ms
コンパイル使用メモリ 37,264 KB
実行使用メモリ 37,540 KB
最終ジャッジ日時 2026-08-07 12:11:43
合計ジャッジ時間 2,715 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #
raw source code

<?php
$str = trim(fgets(STDIN));
$len = strlen($str);
$exists = preg_match("/c.*?w.*?w/", $str);
$min = PHP_INT_MAX;
if($exists) {
  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]));
      }
    }
} else {
    $min=-1;
}
echo $min;
0