結果

問題 No.154 市バス
ユーザー 184184
提出日時 2015-02-17 23:50:01
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 652 bytes
コンパイル時間 371 ms
コンパイル使用メモリ 50,176 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 07:43:20
合計ジャッジ時間 1,028 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

//namaega184
  
int main(){
	int t;scanf("%d",&t);
	char s[1001];
	for(int i=0;i<t;i++){
		scanf("%s",s);
		int len=strlen(s);
		int w=0,g=0,r=0;
		int a=0;
		char lst;
		for(int j=0;j<len;j++){
			lst=s[j];
			if(s[j]=='W')w++;
			else if(s[j]=='G'){
				g++;
				w--;
				if(g>w){
					a=1;
					break;
				}
			}
			else{ 
				r++;
				r--,g--;
				if(r>g||r>w){
					a=1;
					break;
				}
			} 
		} 
		if(a||!r||!g||lst!='R')printf("impossible\n");
		else printf("possible\n");
	}
	
	return 0;
	 
}
0