結果
問題 |
No.154 市バス
|
ユーザー |
|
提出日時 | 2016-08-31 01:17:08 |
言語 | D (dmd 2.109.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 693 bytes |
コンパイル時間 | 659 ms |
コンパイル使用メモリ | 111,948 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-12 03:57:07 |
合計ジャッジ時間 | 1,297 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | AC * 4 WA * 4 |
ソースコード
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) { auto s = readln.chomp; writeln(calc(s) ? "possible" : "impossible"); } } bool calc(string s) { auto a = 0, b = 0, c = 0, d = 0; foreach_reverse (t; s){ switch (t) { case 'R': a += 1; b += 1; break; case 'G': c += 1; b -= 1; if (b < 0) return false; break; case 'W': d += 1; if (c < 0) return false; break; default: } } return a <= d; }