結果
問題 |
No.154 市バス
|
ユーザー |
![]() |
提出日時 | 2016-07-20 15:03:17 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 790 bytes |
コンパイル時間 | 441 ms |
コンパイル使用メモリ | 57,776 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-13 08:39:20 |
合計ジャッジ時間 | 1,090 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | AC * 3 WA * 5 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:43:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 43 | scanf("%d",&n); | ~~~~~^~~~~~~~~
ソースコード
#include <iostream> #include <string> #include <algorithm> #include <stdio.h> void f(){ //始発バスがいきなり終バスでもあるということも考慮すると? int g=0,r=0,w=0; std::string str; std::cin>>str; std::reverse(str.begin(),str.end()); for(int i=0;i<str.size();i++){ char c=str[i]; if(c=='G'){ g++; }else if(c=='R'){ r++; }else if(c=='W'){ w++; } if(((r==0)||(g==0))&&(c=='W')){ printf("impossible\n"); return; } if(g>r){ printf("impossible\n"); return ; } if((r>g)&&(c=='W')){ printf("impossible\n"); return ; } } if((w>=g)&&(g==r)){ printf("possible\n"); }else{ printf("impossible\n"); } } int main() { // your code goes here int n; scanf("%d",&n); for(int i=0;i<n;i++){ f(); } return 0; }