結果
問題 | No.154 市バス |
ユーザー |
![]() |
提出日時 | 2016-06-19 15:32:33 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 764 bytes |
コンパイル時間 | 4,575 ms |
コンパイル使用メモリ | 215,864 KB |
実行使用メモリ | 10,496 KB |
最終ジャッジ日時 | 2024-10-13 08:31:09 |
合計ジャッジ時間 | 18,705 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 1 |
other | AC * 5 WA * 2 TLE * 1 |
ソースコード
#include<iostream> #include<string> #include<regex> using namespace std; string solve(string str){ # define OK "possible" # define NG "impossible" regex re("^W+"); reverse(str.begin(), str.end()); while(!str.empty()){ if(str[0] != 'R') return NG; str.replace(0, 1, ""); int g_index = str.find("G"); if(g_index == -1) return NG; str.replace(g_index, 1, ""); int w_index = str.find("W"); if(w_index == -1) return NG; str.replace(w_index, 1, ""); str = regex_replace(str, re, "", regex_constants::format_first_only); } return OK; } int main(){ int n; cin >> n; for(int i=0; i<n; ++i){ string str; cin >> str; cout << solve(str) << endl; } }