結果

問題 No.154 市バス
ユーザー 👑 horiesinitihoriesiniti
提出日時 2016-07-20 14:43:11
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 726 bytes
コンパイル時間 563 ms
コンパイル使用メモリ 58,008 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-21 09:51:52
合計ジャッジ時間 1,442 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
6,812 KB
testcase_01 AC 27 ms
6,944 KB
testcase_02 AC 27 ms
6,944 KB
testcase_03 AC 27 ms
6,944 KB
testcase_04 WA -
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 24 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:39:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   39 |         scanf("%d",&n);
      |         ~~~~~^~~~~~~~~

ソースコード

diff #

#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