結果

問題 No.154 市バス
ユーザー しらゆきしらゆき
提出日時 2015-12-31 10:16:04
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 70 ms / 2,000 ms
コード長 934 bytes
コンパイル時間 890 ms
コンパイル使用メモリ 104,064 KB
実行使用メモリ 22,528 KB
最終ジャッジ日時 2024-04-21 09:01:48
合計ジャッジ時間 1,908 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
22,528 KB
testcase_01 AC 62 ms
22,272 KB
testcase_02 AC 63 ms
22,144 KB
testcase_03 AC 60 ms
22,400 KB
testcase_04 AC 66 ms
22,272 KB
testcase_05 AC 22 ms
17,920 KB
testcase_06 AC 21 ms
17,408 KB
testcase_07 AC 70 ms
22,016 KB
testcase_08 AC 20 ms
17,792 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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, w = 0;
            string s = Console.ReadLine();
            int cntg = s.Length - s.Replace("G", "").Length;
            for (int j=0; j < s.Length; j++)
            {
                if (s[j] == 'W') w++;
                if (s[j] == 'G') g++;
                if (s[j] == 'R') r++;                
                if (r > g || g > w || (g == cntg && s[j] == 'W'))
                {
                    Console.WriteLine("impossible");
                    break;
                }
                if (j == s.Length - 1)
                {
                    if (s[j] == 'R' && r == g && w >= g) Console.WriteLine("possible");
                    else Console.WriteLine("impossible");
                }
            }
        }
    }
}
0