結果
問題 |
No.154 市バス
|
ユーザー |
![]() |
提出日時 | 2022-12-16 23:28:01 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 27 ms / 2,000 ms |
コード長 | 583 bytes |
コンパイル時間 | 1,995 ms |
コンパイル使用メモリ | 192,456 KB |
最終ジャッジ日時 | 2025-02-09 14:29:16 |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 8 |
ソースコード
#include <bits/stdc++.h> using namespace std; int t; char s[1010]; int main(){ cin>>t; for(int k=0;k<t;++k){ cin>>s; int len=strlen(s),w=0,wc=0,gc=0,i; for(i=len-1;i>=0;--i){ if(s[i]=='G'&&!gc||s[i]=='W'&&!w) break; if(s[i]=='R') ++gc; if(s[i]=='G') --gc,++wc,w=1; if(s[i]=='W'){ if(wc) --wc; w=1; } } if(i>=0||wc||gc) cout<<"impossible"<<endl; else cout<<"possible"<<endl; } return 0; }