結果
問題 |
No.154 市バス
|
ユーザー |
|
提出日時 | 2016-08-31 14:33:00 |
言語 | D (dmd 2.109.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 721 bytes |
コンパイル時間 | 771 ms |
コンパイル使用メモリ | 113,576 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-12 03:59:41 |
合計ジャッジ時間 | 1,419 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 7 WA * 1 |
ソースコード
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); }