結果

問題 No.154 市バス
ユーザー しらゆきしらゆき
提出日時 2015-12-31 09:56:06
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,114 bytes
コンパイル時間 1,102 ms
コンパイル使用メモリ 108,024 KB
実行使用メモリ 31,584 KB
最終ジャッジ日時 2024-04-21 09:01:16
合計ジャッジ時間 2,082 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
27,508 KB
testcase_01 AC 49 ms
29,676 KB
testcase_02 AC 48 ms
29,684 KB
testcase_03 AC 47 ms
31,584 KB
testcase_04 WA -
testcase_05 RE -
testcase_06 RE -
testcase_07 AC 45 ms
27,768 KB
testcase_08 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

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");
                }
            }
        }
    }
}
0