結果
問題 | No.154 市バス |
ユーザー |
![]() |
提出日時 | 2019-03-14 12:39:16 |
言語 | C++11 (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,665 bytes |
コンパイル時間 | 570 ms |
コンパイル使用メモリ | 62,172 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-26 08:04:56 |
合計ジャッジ時間 | 1,445 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | AC * 1 WA * 7 |
ソースコード
#include<iostream> #include<vector> #include<string> using namespace std; int main(){ int T; vector<string> bus_memos; string row; cin >> T; for(int i=0;i<T;i++){ cin >> row; bus_memos.push_back(row); } /** for(int i=0;i<T;i++){ cout<< bus_memos[i] <<endl; for(int j=0;j<bus_memos[i].size();j++){ cout<< bus_memos[i][j] <<endl; } } **/ for(int i=0;i<T;i++){ int T_memo = bus_memos[i].size(); int white=0,green=0,red=0,bus_count=1; bool next=false; bool judge=true; for(int j=0;j<T_memo;j++){ switch(bus_memos[i][j]){ case 'W': white+=1; if(next==true){ bus_count+=1; next=false; } break; case 'G': green+=1; if(next==true){ bus_count+=1; }else{ next=true; } break; case 'R': red+=1; next=true; break; } if(green<red){ judge=false; break; } } if(!(red==bus_count) || bus_count>white) judge=false; //cout<< "whit:" << white << " green:" << green << " red:" << red << " bus_c:"<< bus_count << endl; if(judge){ cout << "possible" << endl; }else{ cout << "impossiblse" << endl; } } return 0; }