結果

問題 No.154 市バス
ユーザー 184184
提出日時 2015-02-17 23:46:42
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 630 bytes
コンパイル時間 513 ms
コンパイル使用メモリ 52,384 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-21 07:41:19
合計ジャッジ時間 899 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
5,248 KB
testcase_01 AC 8 ms
5,376 KB
testcase_02 AC 8 ms
5,376 KB
testcase_03 WA -
testcase_04 AC 8 ms
5,376 KB
testcase_05 WA -
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 6 ms
5,376 KB
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++;
				if(g>w){
					a=1;
					break;
				}
			}
			else{ 
				r++;
				if(r>g||r>w){
					a=1;
					break;
				}
			} 
		} 
		if(a||!r||!g||lst!='R')printf("impossible\n");
		else printf("possible\n");
	}
	
	return 0;
	 
}
0