結果
問題 | No.154 市バス |
ユーザー |
|
提出日時 | 2022-02-09 09:28:04 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 29 ms / 2,000 ms |
コード長 | 484 bytes |
コンパイル時間 | 1,594 ms |
コンパイル使用メモリ | 167,540 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-24 07:51:11 |
合計ジャッジ時間 | 2,300 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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 ans=true; int r=0,g=0,w=0; for(int i=s.size()-1;i>=0;i--){ if(s[i]=='R')r++; if(s[i]=='G')g++; if(s[i]=='W')w++; if(g>r||(w&&!g)){ ans=false; } w=min(w,g); } cout<<(ans&&g==r&&w==g?"possible":"impossible")<<'\n'; } }