結果
問題 | No.345 最小チワワ問題 |
ユーザー |
![]() |
提出日時 | 2016-03-17 14:00:09 |
言語 | PHP (843.2) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,144 bytes |
コンパイル時間 | 3,094 ms |
コンパイル使用メモリ | 31,888 KB |
実行使用メモリ | 32,912 KB |
最終ジャッジ日時 | 2024-09-25 11:39:18 |
合計ジャッジ時間 | 2,762 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 WA * 15 |
コンパイルメッセージ
No syntax errors detected in Main.php
ソースコード
<?php $str = trim(fgets(STDIN)); if(strpos($str,'c') !== false && strpos($str,'w',strpos($str,'c')) !== false && strpos($str,'w',strpos($str,'w',strpos($str,'c'))+1) !== false){ $c_list = str_split($str); $len = 0; $minLen = 99; $msg=""; for($i=0;$i<strlen($str);$i++){ if($c_list[$i] == 'c'){ $msg=$c_list[$i]; $wCnt=0; for($k=1;$k<strlen($str);$k++){ $msg = $msg . $c_list[$i+$k]; if($c_list[$k+$i] == 'w'){ $wCnt=$wCnt+1; } if($wCnt >= 2){ //echo $msg; if($minLen > strlen($msg)){ $minLen = strlen($msg); } break; } } } } printf("$minLen"); }else{ printf("-1"); } function cwwCheck($cStr){ $flg=false; if(strpos($cStr,'c') !== false && strpos($cStr,'w',strpos($cStr,'c')) !== false && strpos($cStr,'w',strpos($cStr,'w',strpos($cStr,'c'))+1) !== false){ $flg=true; } return $flg; }