結果
| 問題 | 
                            No.154 市バス
                             | 
                    
| コンテスト | |
| ユーザー | 
                             しらゆき
                         | 
                    
| 提出日時 | 2015-12-31 09:56:06 | 
| 言語 | C#(csc)  (csc 3.9.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,114 bytes | 
| コンパイル時間 | 733 ms | 
| コンパイル使用メモリ | 104,192 KB | 
| 実行使用メモリ | 21,888 KB | 
| 最終ジャッジ日時 | 2024-10-13 07:53:42 | 
| 合計ジャッジ時間 | 1,612 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | RE * 1 | 
| other | AC * 5 WA * 1 RE * 2 | 
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Linq;
class Program
{
    static void Main()
    {
        int t = int.Parse(Console.ReadLine());
        for (int i=0;i< t; i++)
        {
            int g = 0, r = 0;
            string s = Console.ReadLine();
            int cnt = s.Length - s.Remove('G').Length;
            for (int j=0; j < s.Length; j++)
            {
                if (s[j] == 'G') g++;
                if (s[j] == 'R') r++;
                if (g == cnt && s[j] == 'W')
                {
                    Console.WriteLine("impossible");
                    break;
                }
                if (r > g)
                {
                    Console.WriteLine("impossible");
                    break;
                }
                if (j == s.Length - 1)
                {
                    if (r == g)
                    {
                        if (!(s[j] == 'R')) Console.WriteLine("impossible");
                        else Console.WriteLine("possible");
                    }
                    else Console.WriteLine("impossible");
                }
            }
        }
    }
}
            
            
            
        
            
しらゆき