結果
| 問題 | 
                            No.154 市バス
                             | 
                    
| コンテスト | |
| ユーザー | 
                             kunio_Yb
                         | 
                    
| 提出日時 | 2016-06-20 03:09:07 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 334 bytes | 
| コンパイル時間 | 472 ms | 
| コンパイル使用メモリ | 57,752 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-10-13 08:34:54 | 
| 合計ジャッジ時間 | 1,126 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | WA * 1 | 
| other | AC * 6 WA * 2 | 
コンパイルメッセージ
main.cpp: In function ‘bool f(std::string)’:
main.cpp:12:19: warning: ‘c’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   12 |   return r==g && c=='R';
      |                  ~^~~~~
main.cpp: In function ‘int main()’:
main.cpp:12:19: warning: ‘c’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   12 |   return r==g && c=='R';
      |                  ~^~~~~
main.cpp:5:8: note: ‘c’ was declared here
    5 |   char c;
      |        ^
            
            ソースコード
#include<iostream>
using namespace std;
bool f(string s){
  int g=0,r=0;
  char c;
  for(auto ch : s){
    c=ch;
    g+=(c=='G');
    r+=(c=='R');
    if(r>g) return false;
  }
  return r==g && c=='R';
}
int main(){
  string s;
  int n;
  cin>>n;
  for(int i=0; i<n; ++i){
    cin>>s;
    cout<<(f(s)?"":"im")<<"possible"<<endl;
  }
}
            
            
            
        
            
kunio_Yb