結果

問題 No.154 市バス
ユーザー kunio_Ybkunio_Yb
提出日時 2016-06-20 03:09:07
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 334 bytes
コンパイル時間 431 ms
コンパイル使用メモリ 56,312 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 09:46:26
合計ジャッジ時間 1,151 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
5,248 KB
testcase_01 AC 22 ms
5,376 KB
testcase_02 AC 22 ms
5,376 KB
testcase_03 AC 21 ms
5,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 21 ms
5,376 KB
testcase_08 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;
      |        ^

ソースコード

diff #

#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;
  }
}
0