結果

問題 No.154 市バス
ユーザー mizzsigmizzsig
提出日時 2018-02-04 14:14:45
言語 PHP
(8.3.4)
結果
WA  
実行時間 -
コード長 857 bytes
コンパイル時間 3,065 ms
コンパイル使用メモリ 31,888 KB
実行使用メモリ 32,272 KB
最終ジャッジ日時 2024-04-21 10:29:40
合計ジャッジ時間 1,677 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
31,280 KB
testcase_01 AC 121 ms
31,104 KB
testcase_02 AC 122 ms
31,288 KB
testcase_03 AC 104 ms
31,116 KB
testcase_04 AC 120 ms
31,484 KB
testcase_05 WA -
testcase_06 AC 39 ms
31,244 KB
testcase_07 AC 120 ms
31,428 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;
    } else if (($sum['G'] == 0) || ($sum['R'] == 0)) {
      $isPossible = false;
    }

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