結果
問題 | No.154 市バス |
ユーザー |
|
提出日時 | 2016-09-16 13:51:35 |
言語 | PHP (843.2) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,445 bytes |
コンパイル時間 | 136 ms |
コンパイル使用メモリ | 31,044 KB |
実行使用メモリ | 31,264 KB |
最終ジャッジ日時 | 2024-10-13 08:43:54 |
合計ジャッジ時間 | 1,369 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 7 WA * 1 |
コンパイルメッセージ
No syntax errors detected in Main.php
ソースコード
<?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 || $rpos < $gpos ) // must : start with w , g r exist , r after g{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; }$wcount = substr_count($str, "W");$rcount = substr_count($str, "R");$gcount = substr_count($str, "G");if($rcount != $gcount || $wcount < $gcount) { break; } // must : num(r) = num(g) , num(w) >= num (g) and num (r)for($i = 0; $rcount && $gcount; $i++){switch($str[$i]){case "R":$rcount--;break;case "G":$gcount--;break;case "W":$wcount--;}if($rcount > $gcount || $wcount < $gcount) {break 2;} // too much g after r, too much w after g}$ans = "";break;}echo $ans."possible";echo PHP_EOL;$trial--;}