結果
問題 | No.154 市バス |
ユーザー |
|
提出日時 | 2018-06-09 20:43:43 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 28 ms / 2,000 ms |
コード長 | 1,050 bytes |
コンパイル時間 | 532 ms |
コンパイル使用メモリ | 65,096 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-30 13:01:30 |
合計ジャッジ時間 | 1,758 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 8 |
ソースコード
#include <iostream> #include <string> using namespace std; auto T=0; void input(){ cin >> T; } void solve(){ for(int i=0; i<T; i++){ string s; cin >> s; if(s.size()<3){ cout << "impossible" << endl; continue; } auto r_cnt = 0, g_cnt = 0, w_cnt = 0; bool ans = true, f = false; for(int j=0;j<s.size();j++){ switch(s[j]){ case 'R': r_cnt++; break; case 'G': f=true; g_cnt++; break; case 'W': w_cnt++; f=false; break; } if(!(w_cnt>=g_cnt&&g_cnt>=r_cnt)){ ans = false; break; } } if(g_cnt!=r_cnt||!f) ans = false; if(ans) cout<<"possible" << endl; else cout << "impossible" << endl; } } int main(){ input(); solve(); }