結果

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

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <stdio.h>
void f(){
	//始発バスがいきなり終バスということも考慮すると?
	int g=0,r=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((((r==0)||(g==0)))&&(c=='w')){
			printf("impossible\n");
			return;
		}
		if(c=='G'){
			g++;
		}else if(c=='R'){
			r++;
		}
		if(g>r){
			printf("impossible\n");
			return ;
		}
	}
	printf("possible\n");
}

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