結果

問題 No.154 市バス
ユーザー kunio_Yb
提出日時 2016-06-20 03:19:57
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 393 bytes
コンパイル時間 415 ms
コンパイル使用メモリ 56,804 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-13 08:34:55
合計ジャッジ時間 1,113 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other AC * 6 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
using namespace std;
bool f(string s){
  int g=0,r=0,w=0;
  char c;
  for(auto i=s.rbegin(),e=s.rend();i!=e;++i){
    c=*i;
    g+=(c=='G');
    r+=(c=='R');
    w+=(c=='W');
    if(r<g || (r==0&&w!=0)) return false;
  }
  return r==g&&r<=w;
}
int main(){
  string s;
  int n;
  cin>>n;
  for(int i=0; i<n; ++i){
    cin>>s;
    cout<<(f(s)?"":"im")<<"possible"<<endl;
  }
}
0