結果

問題 No.154 市バス
ユーザー papinianuspapinianus
提出日時 2016-09-16 09:42:16
言語 PHP
(8.3.4)
結果
WA  
実行時間 -
コード長 1,260 bytes
コンパイル時間 104 ms
コンパイル使用メモリ 32,276 KB
実行使用メモリ 32,400 KB
最終ジャッジ日時 2024-04-21 09:55:49
合計ジャッジ時間 1,567 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
31,056 KB
testcase_01 AC 71 ms
30,888 KB
testcase_02 AC 69 ms
31,196 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 38 ms
30,656 KB
testcase_06 AC 39 ms
30,848 KB
testcase_07 AC 65 ms
30,940 KB
testcase_08 AC 37 ms
30,752 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
$trial = trim(fgets(STDIN));
while($trial)
{
    $ans = "im";
    while(true)
    {
        $str = trim(fgets(STDIN));
        $wpos = strpos($str, "W");
        $gpos = strpos($str, "G");
        $rpos = strpos($str, "R");
        $len = strlen($str);
        if($wpos !== 0 || $gpos === false || $rpos === false || $gpos < 1 || $rpos < $gpos )
        {
            break;
        }
        $str = strrev($str);
        $len = strlen($str);
        $wpos = strpos($str, "W");
        $gpos = strpos($str, "G");
        $rpos = strpos($str, "R");
        if($rpos !== 0 || $wpos < $gpos) { break; }
        $rcount = substr_count($str, "R");
        $gcount = substr_count($str, "G");
        if($rcount < 1 || $gcount < 1 || $rcount != $gcount) { echo __LINE__.PHP_EOL; flush();break; }
        for($i = 0; $rcount && $gcount; $i++)
        {
            switch($str[$i])
            {
                case "R":
                    $rcount--;
                    break;
                case "G":
                    $gcount--;
                    break;
            }
            if($rcount > $gcount) {echo __LINE__.PHP_EOL;flush();break 2;}
        }
        $ans = "";
        break;
    }
    echo $ans."possible";
    echo PHP_EOL;
    $trial--;
}
0