結果

問題 No.154 市バス
コンテスト
ユーザー 紙ぺーぱー
提出日時 2016-06-20 01:10:53
言語 C++14
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 17 ms / 2,000 ms
+ 437µs
コード長 400 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 916 ms
コンパイル使用メモリ 183,408 KB
実行使用メモリ 6,528 KB
最終ジャッジ日時 2026-09-15 13:20:14
合計ジャッジ時間 2,152 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 8
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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