結果
問題 |
No.154 市バス
|
ユーザー |
|
提出日時 | 2025-07-23 13:16:15 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 8 ms / 2,000 ms |
コード長 | 702 bytes |
コンパイル時間 | 1,859 ms |
コンパイル使用メモリ | 195,244 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-07-23 13:16:18 |
合計ジャッジ時間 | 2,889 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 8 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int T; cin >> T; while(T--){ string s; cin >> s; bool ok = true; int Ws = 0,Gs = 0,Rs = 0; for(auto c : s){ if(c == 'W') Ws++; else if(c == 'G') Gs++; else Rs++; if(Ws < Gs || Gs < Rs) ok = false; } if(Gs != Rs || Rs == 0) ok = false; if(s.back() != 'R') ok = false; for(int i=s.size(); i--;){ if(s.at(i) == 'G') break; else if(s.at(i) == 'W'){ok = false; break;} } cout << (ok?"possible":"impossible") << "\n"; } }