結果
問題 |
No.154 市バス
|
ユーザー |
|
提出日時 | 2016-02-05 23:05:05 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,068 bytes |
コンパイル時間 | 506 ms |
コンパイル使用メモリ | 66,600 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-13 08:00:02 |
合計ジャッジ時間 | 1,222 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | AC * 2 WA * 6 |
ソースコード
#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <cstring> #include <algorithm> #include <limits.h> #include <cmath> #include <cstdio> #include <vector> #include <set> #include <string> #define REP(i,a,b) for(i=a;i<b;i++) #define rep(i,n) REP(i,0,n) using namespace std; typedef long long ll; typedef unsigned long long ull; bool possible(char S[]) { int i; int n = strlen(S); int Gcnt = 0,Rcnt = 0,Wcnt = 0; bool possible = true; // R より Gの方が先に来てないか判定 rep(i,n) { if(S[i] == 'G') Gcnt++; else if(S[i] == 'R') Rcnt++; else Wcnt++; if(Gcnt < Rcnt) { possible = false; break; } } if(Rcnt != Gcnt) possible = false; if(S[n-1] != 'R') possible = false; for(i=n-2;i>-1;i--) { if(S[i] == 'W') possible = false; else if(S[i] == 'B') break; } // 3本以上走ってるか return possible; } int main(void) { int i,j,k,l; int T; char S[1005] = ""; cin >> T; while(cin >> S) { if(possible(S)) puts("possible"); else puts("impossible"); } return 0; }