結果

問題 No.154 市バス
ユーザー ttakanottakano
提出日時 2017-11-28 01:37:45
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 659 bytes
コンパイル時間 1,772 ms
コンパイル使用メモリ 159,084 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 10:28:24
合計ジャッジ時間 2,180 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 22 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;
    bool flag=1;
    REP(j,GET_ARRAY_SIZE(s)){
      if(s[j]=='G'){cnt++;}
      else if(s[j]=='R'){cnt--;}
      if(cnt<0)flag=0;
      //print(s[j]<<" "<<cnt);
    }
    string ans=cnt==0&&flag?"possible":"impossible";
    print(ans);
  }
}
0