結果

問題 No.154 市バス
ユーザー mizzsigmizzsig
提出日時 2018-02-04 14:12:21
言語 PHP
(8.3.4)
結果
WA  
実行時間 -
コード長 775 bytes
コンパイル時間 1,639 ms
コンパイル使用メモリ 30,668 KB
実行使用メモリ 31,300 KB
最終ジャッジ日時 2024-04-21 10:29:34
合計ジャッジ時間 3,511 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
30,600 KB
testcase_01 AC 127 ms
30,612 KB
testcase_02 AC 128 ms
30,960 KB
testcase_03 AC 103 ms
30,936 KB
testcase_04 AC 123 ms
30,960 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 122 ms
30,924 KB
testcase_08 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
  $n = trim(fgets(STDIN));

  for ($i = 0; $i < $n; $i++) {
    $str = trim(fgets(STDIN));

    $length = strlen($str);

    $sum['W'] = 0;
    $sum['G'] = 0;
    $sum['R'] = 0;

    $isPossible = true;
    // それぞれのテストケースを確認
    for ($l = 0; $l < $length; $l++) {
      $sum[$str[$l]]++;

      if ($sum['G'] < $sum['R']) {
        $isPossible = false;
        break;
      } else if (($sum['W'] < $sum['G']) || ($sum['W'] < $sum['R'])) {
        $isPossible = false;
        break;
      }
    }

    if ($sum['G'] != $sum['R']) {
      $isPossible = false;
    } else if ($sum['W'] < $sum['G']) {
      $isPossible = false;
    }

    if ($isPossible) {
      echo 'possible' . "\n";
    } else {
      echo 'impossible' . "\n";
    }
  }
0