結果

問題 No.154 市バス
ユーザー 紙ぺーぱー
提出日時 2016-06-20 01:10:53
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 400 bytes
コンパイル時間 1,389 ms
コンパイル使用メモリ 168,464 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-13 08:34:25
合計ジャッジ時間 2,118 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
bool f(string s){
  int w=0,g=0,r=0,R=0;
  for(auto x :s)R+=x=='R';
  bool ok=1;
  for(auto x :s){
    if(x=='G'){ g++; ok&=w>=g+r;}
    else if(x=='R'){g--;r++;ok&=g>=0;}
    else{w++; ok&=r+g<R;}
  }
  ok&=g==0&&r==R;
  return ok;
}
int main(){
 int T; cin>>T;
 while(T--){
    string s;cin>>s;
    if(!f(s))cout<<"im";
    cout<<"possible"<<endl;
 }
}
0