結果

問題 No.154 市バス
ユーザー itezpaceitezpace
提出日時 2016-07-25 23:36:28
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 741 bytes
コンパイル時間 524 ms
コンパイル使用メモリ 56,516 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-21 09:54:09
合計ジャッジ時間 1,452 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
6,812 KB
testcase_01 AC 28 ms
6,940 KB
testcase_02 AC 27 ms
6,944 KB
testcase_03 AC 26 ms
6,944 KB
testcase_04 AC 26 ms
6,944 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 23 ms
6,940 KB
testcase_08 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:37:5: warning: ‘f’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   37 |     if(f==0){
      |     ^~

ソースコード

diff #

#include <iostream>
#include <string>
using namespace std;

int main(){
  int t;
  cin>>t;
  string s;
  for(int i=0; i<t; ++i){
    cin>>s;
    int w,g,r,f;
    w=0;
    g=0;
    r=0;
    for(int j=0; j<s.size(); ++j){
      f=0;
      if(s[j]=='W') w++;
      if(s[j]=='G'){
        if(w>g){
          g++;
        } else {
          f=1;
          cout<<"impossible"<<endl;
          break;
        }
      }
      if(s[j]=='R'){
        if(w>=g && g>r){
          r++;
        } else {
          f=1;
          cout<<"impossible"<<endl;
          break;
        }
      }
    }
    if(f==0){
      if(w>=g && w>=r && g==r){
        cout<<"possible"<<endl;
      } else {
        cout<<"impossible"<<endl;
      }
    }
  }
  return 0;
}
0