結果

問題 No.345 最小チワワ問題
ユーザー 重荷重荷
提出日時 2016-03-17 14:00:09
言語 PHP
(8.3.4)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,144 bytes
コンパイル時間 1,422 ms
コンパイル使用メモリ 32,624 KB
実行使用メモリ 32,916 KB
最終ジャッジ日時 2023-10-26 03:46:00
合計ジャッジ時間 3,066 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
32,788 KB
testcase_01 AC 44 ms
32,788 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 44 ms
32,788 KB
testcase_06 AC 45 ms
32,788 KB
testcase_07 AC 44 ms
32,728 KB
testcase_08 AC 44 ms
32,728 KB
testcase_09 AC 44 ms
32,728 KB
testcase_10 AC 45 ms
32,788 KB
testcase_11 AC 44 ms
32,728 KB
testcase_12 AC 44 ms
32,728 KB
testcase_13 AC 45 ms
32,732 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 45 ms
32,788 KB
testcase_20 AC 44 ms
32,788 KB
testcase_21 AC 44 ms
32,728 KB
testcase_22 AC 44 ms
32,788 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 44 ms
32,728 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 44 ms
32,728 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?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;
}
0