結果

問題 No.154 市バス
ユーザー 紙ぺーぱー紙ぺーぱー
提出日時 2016-06-20 01:10:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 400 bytes
コンパイル時間 1,489 ms
コンパイル使用メモリ 164,004 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 09:46:04
合計ジャッジ時間 2,200 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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