結果
問題 |
No.154 市バス
|
ユーザー |
![]() |
提出日時 | 2016-06-10 23:27:13 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 9 ms / 2,000 ms |
コード長 | 705 bytes |
コンパイル時間 | 1,469 ms |
コンパイル使用メモリ | 167,120 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-13 08:23:57 |
合計ジャッジ時間 | 2,362 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 8 |
ソースコード
#include <bits/stdc++.h> using namespace std; struct INIT{INIT(){ios::sync_with_stdio(false);cin.tie(0);}}init; bool check(string S){ int white_count(0),green_count(0),white_exist(0); for(auto& it : S) switch(it){ case 'W':white_count++;white_exist=1;break; case 'G':green_count++;white_exist=0; if(white_count--<=0)return false;break; case 'R':if(green_count--<=0)return false;break; } return green_count==0&&white_exist==0; } int main() { int T; cin>>T; while(T--){ string S; cin>>S; if(check(S))cout<<"possible"<<endl; else cout<<"impossible"<<endl; } return 0; }