結果

問題 No.154 市バス
ユーザー yun_appyun_app
提出日時 2016-06-10 23:59:12
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,222 bytes
コンパイル時間 1,966 ms
コンパイル使用メモリ 74,188 KB
実行使用メモリ 51,208 KB
最終ジャッジ日時 2024-04-21 09:31:52
合計ジャッジ時間 6,523 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 565 ms
51,180 KB
testcase_01 AC 579 ms
51,160 KB
testcase_02 AC 545 ms
51,208 KB
testcase_03 AC 515 ms
49,300 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 50 ms
36,712 KB
testcase_07 AC 528 ms
51,184 KB
testcase_08 WA -
権限があれば一括ダウンロードができます

ソースコード

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().split("");
            int bus = 0;
            int g=0;
            int r=0;
            int ww=0;
            boolean w = false;
            for(String st:str){
                if(st.equals("G")){
                    bus++;
                    g++;
                }else if(st.equals("R")){
                    bus--;
                    r++;
                    if(bus<0){
                        System.out.println("impossible");
                        continue start;
                    }
                    w = false;
                }else if(st.equals("W")){
                    w = true;
                    ww++;
                }
            }
            if(w||bus!=0||g>ww){
                System.out.println("impossible");
            }else{
                System.out.println("possible");
            }
        }
    }
}

0