結果

問題 No.154 市バス
コンテスト
ユーザー horiesiniti
提出日時 2016-07-20 14:43:11
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 726 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 521 ms
コンパイル使用メモリ 74,604 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-04-30 17:41:53
合計ジャッジ時間 1,383 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 7 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <string>
#include <algorithm>
#include <stdio.h>
void f(){
	//始発バスがいきなり終バスでもあるということも考慮すると?
	int g=0,r=0,w=0;
	std::string str;
	std::cin>>str;
	std::reverse(str.begin(),str.end());
	for(int i=0;i<str.size();i++){
		char c=str[i];
		if(c=='G'){
			g++;
		}else if(c=='R'){
			r++;
		}else if(c=='W'){
			w++;
		}
		if((((r==0)||(g==0)))&&(c=='W')){
			printf("impossible\n");
			return;
		}
		if(g>r){
			printf("impossible\n");
			return ;
		}
	}
	if((w>=g)&&(g==r)){
		printf("possible\n");
	}else{
		printf("impossible\n");
	}
}

int main() {
	// your code goes here
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		f();
	}
	
	return 0;
}
0