結果
問題 | No.154 市バス |
ユーザー |
![]() |
提出日時 | 2015-02-24 21:39:42 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 429 ms / 2,000 ms |
コード長 | 1,195 bytes |
コンパイル時間 | 1,999 ms |
コンパイル使用メモリ | 77,044 KB |
実行使用メモリ | 45,428 KB |
最終ジャッジ日時 | 2024-10-13 07:05:06 |
合計ジャッジ時間 | 6,002 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 8 |
ソースコード
import java.math.*; import java.util.*; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); ee:for(int i=0;i<t;i++){ String string = sc.next(); int gc=0; int rc=0; int wc=0; boolean flag=true; for(int j=0;j<string.length();j++){ if(string.charAt(j)=='G') gc++; if(string.charAt(j)=='R') rc++; if(string.charAt(j)=='W') wc++; if(gc<rc){ System.out.println("impossible"); continue ee; } if(wc<gc){ System.out.println("impossible"); continue ee; } } if(gc==0||rc==0||wc==0){ System.out.println("impossible"); continue; } if(wc<gc){ System.out.println("impossible"); continue; } if(gc!=rc){ System.out.println("impossible"); continue; } if(string.lastIndexOf("R")<string.lastIndexOf("G")){ System.out.println("impossible"); continue; } if(string.lastIndexOf("G")<string.lastIndexOf("W")){ System.out.println("impossible"); continue; } if(string.indexOf("R")<string.indexOf("G")){ System.out.println("impossible"); continue; } System.out.println("possible"); } } }