結果

問題 No.154 市バス
ユーザー te-shte-sh
提出日時 2016-08-31 14:33:00
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 721 bytes
コンパイル時間 615 ms
コンパイル使用メモリ 99,388 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-09-02 21:44:35
合計ジャッジ時間 1,446 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
4,372 KB
testcase_01 AC 9 ms
4,372 KB
testcase_02 AC 9 ms
4,368 KB
testcase_03 AC 8 ms
4,372 KB
testcase_04 WA -
testcase_05 AC 1 ms
4,372 KB
testcase_06 AC 1 ms
4,368 KB
testcase_07 AC 6 ms
4,368 KB
testcase_08 AC 1 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.algorithm, std.array, std.container, std.range;
import std.numeric, std.math, std.bigint, std.bitmanip, std.random;
import std.string, std.conv, std.stdio, std.typecons;

void main()
{
  auto t = readln.chomp.to!int;

  foreach (_; 0..t)
    writeln(calc(readln.chomp) ? "possible" : "impossible");
}

bool calc(string s)
{
  auto a = 0, b = 0, c = 0, d1 = false, d2 = false;

  foreach_reverse (t; s) {
    switch (t) {
    case 'R':
      a += 1;
      break;
    case 'G':
      b += 1;
      if (a < b) return false;
      d1 = true;
      d2 = false;
      break;
    case 'W':
      if (!d1) return false;
      d2 = true;
      break;
    default: assert(0);
    }
  }

  return (a == b && d1 && d2);
}
0