結果
| 問題 | 
                            No.154 市バス
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2016-08-30 12:05:45 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 708 bytes | 
| コンパイル時間 | 514 ms | 
| コンパイル使用メモリ | 65,400 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-10-13 08:42:27 | 
| 合計ジャッジ時間 | 1,249 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | WA * 1 | 
| other | AC * 7 WA * 1 | 
ソースコード
#include <string>
#include <iostream>
#include <cstdint>
typedef int_fast16_t int16;
int main() {
	int16 n;
	std::cin>>n;
	std::string a;
	std::getline(std::cin,a);
	for(int i=0;i<n;i++){
		bool is_error=false;
		std::string case_;
		std::getline(std::cin,case_);
		int red_num=0;
		int green_num=0;
                for(auto color:case_){
			switch(color){
			case 'R':
				red_num++;
				break;
			case 'G':
				green_num++;
				break;
			}
			if(red_num>green_num){
				is_error=true;
			}
		}
		auto last=case_.rbegin();
		auto last2=last;
		++last2;
		if(*last=='W'||*last2=='W'||red_num!=green_num||is_error){
			std::cout<<"impossible"<<std::endl;
		}else{
			std::cout<<"possible"<<std::endl;
		}
	}
}