結果
問題 | No.154 市バス |
ユーザー |
![]() |
提出日時 | 2016-06-11 00:16:35 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,237 bytes |
コンパイル時間 | 1,890 ms |
コンパイル使用メモリ | 75,216 KB |
実行使用メモリ | 53,796 KB |
最終ジャッジ日時 | 2024-10-13 08:25:03 |
合計ジャッジ時間 | 4,120 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 7 WA * 1 |
ソースコード
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"); } } }