結果
問題 | No.154 市バス |
ユーザー |
|
提出日時 | 2022-08-13 15:17:53 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 710 bytes |
コンパイル時間 | 1,990 ms |
コンパイル使用メモリ | 194,424 KB |
最終ジャッジ日時 | 2025-01-30 22:12:48 |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | AC * 6 WA * 2 |
ソースコード
#include <bits/stdc++.h>#define rep(i,n) for(int i = 0; i < (n); i++)using namespace std;typedef long long ll;int main(){cin.tie(0);ios::sync_with_stdio(0);int T; cin >> T;rep(_,T) {string S; cin >> S;int W = 0, G = 0, R = 0;int N = S.size();int ans = 1;rep(i,N) {if(S[i] == 'W') W++;if(S[i] == 'G') {G++, W--;if(W < 0){ ans = 0; break; }}if(S[i] == 'R') {R++, G--;if(G < 0){ ans = 0; break; }}}if(G > 0) ans = 0;cout << string(ans ? "" : "im") + "possible" << endl;}}