結果

問題 No.154 市バス
ユーザー ttakanottakano
提出日時 2017-11-28 10:44:39
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 774 bytes
コンパイル時間 1,450 ms
コンパイル使用メモリ 159,104 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-21 10:28:30
合計ジャッジ時間 2,305 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define GET_ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 1000000007;

int main(){
  int n;
  cin>>n;
  REP(i,n){
    string s;
    cin>>s;
    int cnt=0;
    int w=0;
    int gr=0;
    bool flag=1;
    REP(j,GET_ARRAY_SIZE(s)){
      if(s[j]=='G'){
        cnt++;
        if(cnt==0)gr++;
      }
      else if(s[j]=='R'){
        cnt--;
        if(cnt==0)gr++;
      }
      else if(s[j]=='W'){w++;}
      if(cnt<0)flag=0;
    }
    string ans=cnt==0&&flag&&gr<=w?"possible":"impossible";
    print(ans);
  }
}
0