結果

問題 No.154 市バス
ユーザー yun_appyun_app
提出日時 2016-06-11 00:16:35
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,237 bytes
コンパイル時間 2,633 ms
コンパイル使用メモリ 74,740 KB
実行使用メモリ 53,712 KB
最終ジャッジ日時 2024-04-21 09:31:57
合計ジャッジ時間 5,310 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 257 ms
53,080 KB
testcase_01 AC 245 ms
53,384 KB
testcase_02 AC 256 ms
53,504 KB
testcase_03 AC 247 ms
53,312 KB
testcase_04 WA -
testcase_05 AC 68 ms
49,612 KB
testcase_06 AC 70 ms
50,076 KB
testcase_07 AC 248 ms
53,220 KB
testcase_08 AC 69 ms
50,140 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.lang.*;
import java.io.*;

class Ideone{
    public static void main(String[] args) throws Exception{
        // your code goes here
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        
        start:for(int i=0;i<n;i++){
            String str = br.readLine();
            int bus = 0;
            int r = 0;
            int w = 0;
            for(int j=str.length()-1;j>=0;j--){
                char c = str.charAt(j);
                if(c=='W'){
                    if(bus==0){
                        System.out.println("impossible");
                        continue start;
                    }
                    w++;
                }else if(c=='R'){
                    r++;
                }else if(c=='G'){
                    if(r==0){
                        System.out.println("impossible");
                        continue start;
                    }
                    r--;
                    bus++;
                }
            }
            if(r==0 && w>=bus)
                System.out.println("possible");
            else
                System.out.println("impossible");
        }
    }
}

0