結果
問題 | No.154 市バス |
ユーザー |
![]() |
提出日時 | 2015-02-18 00:15:35 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 13 ms / 2,000 ms |
コード長 | 946 bytes |
コンパイル時間 | 320 ms |
コンパイル使用メモリ | 50,944 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-13 06:36:35 |
合計ジャッジ時間 | 956 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 8 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:13:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 13 | int t;scanf("%d",&t); | ~~~~~^~~~~~~~~ main.cpp:16:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 16 | scanf("%s",s); | ~~~~~^~~~~~~~
ソースコード
#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <map>#include <vector>#include <algorithm>using namespace std;//namaega184int main(){int t;scanf("%d",&t);char s[1001];for(int i=0;i<t;i++){scanf("%s",s);int len=strlen(s);int w=0,g=0,r=0;int a=0,gg=0,rr=0;char lst;for(int j=len-1;j>=0;j--){if(s[j]=='W'){w++;if(r==0||g==0){a=1;break;}}else if(s[j]=='G'){g++;if( g>r){a=1;break;}}else{r++;if( g>r){a=1;break;}}}if(a||!r||!g){printf("impossible\n");continue;}w=0,g=0,r=0;a=0,gg=0,rr=0;for(int j=0;j<len;j++){if(s[j]=='W')w++;else if(s[j]=='G'){g++;if(g>w){a=1;break;}}else{r++;if(r>w||r>g){a=1;break;}}}if(a||!r||!g)printf("impossible\n");else printf("possible\n");}return 0;}