結果
問題 |
No.154 市バス
|
ユーザー |
![]() |
提出日時 | 2016-07-20 14:43:11 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 726 bytes |
コンパイル時間 | 429 ms |
コンパイル使用メモリ | 58,868 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-13 08:39:19 |
合計ジャッジ時間 | 1,113 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 7 WA * 1 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:39:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 39 | 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((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; }