結果
問題 |
No.154 市バス
|
ユーザー |
|
提出日時 | 2021-03-20 19:34:47 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 39 ms / 2,000 ms |
コード長 | 912 bytes |
コンパイル時間 | 2,748 ms |
コンパイル使用メモリ | 192,352 KB |
最終ジャッジ日時 | 2025-01-19 20:25:53 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 8 |
ソースコード
#include<bits/stdc++.h> using namespace std; int main(){ int t; cin >> t; while(t--){ string s; cin >> s; bool ok = true; int w = 0,g = 0,r = 0; for(int i=s.size()-1;i >= 0;i--){ if(s[i] == 'R'){ r++; }else if(s[i] == 'G'){ if(r >= 1){ g++;r--; } else{ ok = false; break; } }else if(s[i] == 'W'){ if(g >= 1){ w++;g--; }else if(w >= 1){ w++; }else{ ok = false; break; } } } if(g != 0 || r != 0) ok = false; cout << (ok ? "possible" : "impossible") << endl; } return 0; }